attp-client 0.0.1__tar.gz

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.
Files changed (33) hide show
  1. attp_client-0.0.1/PKG-INFO +278 -0
  2. attp_client-0.0.1/README.md +260 -0
  3. attp_client-0.0.1/pyproject.toml +27 -0
  4. attp_client-0.0.1/src/attp_client/catalog.py +59 -0
  5. attp_client-0.0.1/src/attp_client/client.py +119 -0
  6. attp_client-0.0.1/src/attp_client/consts.py +1 -0
  7. attp_client-0.0.1/src/attp_client/errors/attp_exception.py +12 -0
  8. attp_client-0.0.1/src/attp_client/errors/correlated_rpc_exception.py +21 -0
  9. attp_client-0.0.1/src/attp_client/errors/dead_session.py +7 -0
  10. attp_client-0.0.1/src/attp_client/errors/not_found.py +2 -0
  11. attp_client-0.0.1/src/attp_client/errors/serialization_error.py +6 -0
  12. attp_client-0.0.1/src/attp_client/errors/unauthenticated_error.py +2 -0
  13. attp_client-0.0.1/src/attp_client/inference.py +131 -0
  14. attp_client-0.0.1/src/attp_client/interfaces/catalogs/catalog.py +6 -0
  15. attp_client-0.0.1/src/attp_client/interfaces/error.py +6 -0
  16. attp_client-0.0.1/src/attp_client/interfaces/handshake/auth.py +9 -0
  17. attp_client-0.0.1/src/attp_client/interfaces/handshake/hello.py +13 -0
  18. attp_client-0.0.1/src/attp_client/interfaces/handshake/ready.py +11 -0
  19. attp_client-0.0.1/src/attp_client/interfaces/inference/enums/message_data_type.py +14 -0
  20. attp_client-0.0.1/src/attp_client/interfaces/inference/enums/message_emergency_type.py +11 -0
  21. attp_client-0.0.1/src/attp_client/interfaces/inference/enums/message_type.py +18 -0
  22. attp_client-0.0.1/src/attp_client/interfaces/inference/message.py +51 -0
  23. attp_client-0.0.1/src/attp_client/interfaces/inference/tool.py +6 -0
  24. attp_client-0.0.1/src/attp_client/interfaces/route_mappings.py +12 -0
  25. attp_client-0.0.1/src/attp_client/misc/fixed_basemodel.py +63 -0
  26. attp_client-0.0.1/src/attp_client/misc/serializable.py +69 -0
  27. attp_client-0.0.1/src/attp_client/router.py +113 -0
  28. attp_client-0.0.1/src/attp_client/session.py +316 -0
  29. attp_client-0.0.1/src/attp_client/tools.py +59 -0
  30. attp_client-0.0.1/src/attp_client/types/route_mapping.py +14 -0
  31. attp_client-0.0.1/src/attp_client/utils/context_awaiter.py +40 -0
  32. attp_client-0.0.1/src/attp_client/utils/route_mapper.py +18 -0
  33. attp_client-0.0.1/src/attp_client/utils/serializer.py +25 -0
@@ -0,0 +1,278 @@
1
+ Metadata-Version: 2.3
2
+ Name: attp-client
3
+ Version: 0.0.1
4
+ Summary: A python-sdk client for interacting with AgentHub's ATTP protocol (Agent Tool Transport Protocol)
5
+ License: MIT
6
+ Author: Ascender Team
7
+ Requires-Python: >=3.11,<3.14
8
+ Classifier: License :: OSI Approved :: MIT License
9
+ Classifier: Programming Language :: Python :: 3
10
+ Classifier: Programming Language :: Python :: 3.11
11
+ Classifier: Programming Language :: Python :: 3.12
12
+ Classifier: Programming Language :: Python :: 3.13
13
+ Requires-Dist: ascender-framework (>=2.0rc7,<3.0)
14
+ Requires-Dist: attp-core (==0.1.10)
15
+ Requires-Dist: msgpack (>=1.1.1,<2.0.0)
16
+ Requires-Dist: pydantic (>=2.11.7,<3.0.0)
17
+ Description-Content-Type: text/markdown
18
+
19
+ # ATTP Client
20
+
21
+ A Python SDK client for interacting with AgentHub's ATTP (Agent Tool Transport Protocol).
22
+
23
+ ## Overview
24
+
25
+ The ATTP Client provides a comprehensive Python interface for connecting to and interacting with AgentHub's ATTP protocol. It enables real-time communication with AI agents, tool management, and inference operations through a high-performance async/await interface.
26
+
27
+ ## Features
28
+
29
+ - **Async/Await Support**: Built with modern Python async patterns for optimal performance
30
+ - **Agent Communication**: Direct communication with AI agents through the ATTP protocol
31
+ - **Tool Management**: Register, unregister, and manage tools in organized catalogs
32
+ - **Inference API**: Invoke AI agent inference with configurable parameters
33
+ - **Real-time Messaging**: Stream responses and handle real-time agent interactions
34
+ - **Event Handling**: Register custom event handlers for connect/disconnect and custom routes
35
+ - **Authentication**: Secure token-based authentication with organization support
36
+
37
+ ## Installation
38
+
39
+ ```bash
40
+ pip install attp-client
41
+ ```
42
+
43
+ Or with Poetry:
44
+
45
+ ```bash
46
+ poetry add attp-client
47
+ ```
48
+
49
+ ## Quick Start
50
+
51
+ ### Basic Connection
52
+
53
+ ```python
54
+ import asyncio
55
+ from attp_client.client import ATTPClient
56
+
57
+ async def main():
58
+ # Initialize the client
59
+ client = ATTPClient(
60
+ agt_token="your_agent_token_here",
61
+ organization_id=1,
62
+ connection_url="attp://localhost:6563" # Optional, defaults to localhost
63
+ )
64
+
65
+ # Connect to AgentHub
66
+ await client.connect()
67
+
68
+ # Your code here...
69
+
70
+ # Close the connection
71
+ await client.close()
72
+
73
+ if __name__ == "__main__":
74
+ asyncio.run(main())
75
+ ```
76
+
77
+ ### Agent Inference
78
+
79
+ ```python
80
+ from attp_client.interfaces.inference.message import IMessageDTOV2
81
+ from attp_client.interfaces.inference.enums.message_type import MessageTypeEnum
82
+ from uuid import UUID
83
+
84
+ # Invoke inference by agent ID
85
+ response = await client.inference.invoke_inference(
86
+ agent_id=17,
87
+ input_configuration={},
88
+ messages=[
89
+ IMessageDTOV2(
90
+ content="Hello, how can you help me?",
91
+ message_type=MessageTypeEnum.USER_MESSAGE,
92
+ chat_id=UUID("your-chat-id-here")
93
+ )
94
+ ],
95
+ stream=False,
96
+ timeout=30
97
+ )
98
+
99
+ print("Agent response:", response)
100
+ ```
101
+
102
+ ### Tool Management
103
+
104
+ ```python
105
+ # Register a tool
106
+ tool_id = await client.tools.register(
107
+ catalog_name="my_catalog",
108
+ name="example_tool",
109
+ description="An example tool for demonstration",
110
+ schema_id="tool_schema_v1",
111
+ return_direct=False,
112
+ timeout_ms=20000
113
+ )
114
+
115
+ # Access a specific catalog
116
+ catalog = await client.catalog("my_catalog")
117
+
118
+ # Unregister a tool
119
+ await client.tools.unregister("my_catalog", str(tool_id))
120
+ ```
121
+
122
+ ### Event Handling
123
+
124
+ ```python
125
+ def on_connect():
126
+ print("Connected to AgentHub!")
127
+
128
+ def on_disconnect():
129
+ print("Disconnected from AgentHub!")
130
+
131
+ def handle_custom_event(data):
132
+ print(f"Received custom event: {data}")
133
+
134
+ # Register event handlers
135
+ client.add_event_handler("", "connect", on_connect)
136
+ client.add_event_handler("", "disconnect", on_disconnect)
137
+ client.add_event_handler("custom:pattern", "custom", handle_custom_event)
138
+ ```
139
+
140
+ ## Configuration
141
+
142
+ ### Client Parameters
143
+
144
+ - `agt_token` (str): Your AgentHub authentication token
145
+ - `organization_id` (int): Your organization ID
146
+ - `connection_url` (str, optional): ATTP server URL (default: "attp://localhost:6563")
147
+ - `max_retries` (int, optional): Maximum connection retry attempts (default: 20)
148
+ - `limits` (Limits, optional): Connection limits configuration
149
+ - `logger` (Logger, optional): Custom logger instance
150
+
151
+ ### Connection Limits
152
+
153
+ ```python
154
+ from attp_core.rs_api import Limits
155
+
156
+ limits = Limits(max_payload_size=50000)
157
+ client = ATTPClient(
158
+ agt_token="...",
159
+ organization_id=1,
160
+ limits=limits
161
+ )
162
+ ```
163
+
164
+ ## API Reference
165
+
166
+ ### ATTPClient
167
+
168
+ The main client class for ATTP communication.
169
+
170
+ #### Methods
171
+
172
+ - `connect()`: Establish connection to AgentHub
173
+ - `close()`: Close the connection
174
+ - `catalog(catalog_name: str)`: Access a specific tool catalog
175
+ - `add_event_handler(pattern: str, route_type: RouteType, callback: Callable)`: Register event handlers
176
+
177
+ #### Properties
178
+
179
+ - `inference`: Access to the inference API
180
+ - `tools`: Access to the tools manager
181
+ - `router`: Access to the low-level router
182
+
183
+ ### AttpInferenceAPI
184
+
185
+ Handles AI agent inference operations.
186
+
187
+ #### Methods
188
+
189
+ - `invoke_inference()`: Invoke inference for a specific agent
190
+ - `invoke_chat_inference()`: Invoke inference for a chat session
191
+
192
+ ### ToolsManager
193
+
194
+ Manages tool registration and organization.
195
+
196
+ #### Methods
197
+
198
+ - `register()`: Register a new tool
199
+ - `unregister()`: Remove tool registration
200
+
201
+ ## Error Handling
202
+
203
+ The client includes comprehensive error handling:
204
+
205
+ ```python
206
+ from attp_client.errors import (
207
+ AttpException,
208
+ DeadSessionError,
209
+ NotFoundError,
210
+ SerializationError,
211
+ UnauthenticatedError
212
+ )
213
+
214
+ try:
215
+ await client.connect()
216
+ except UnauthenticatedError:
217
+ print("Authentication failed - check your token")
218
+ except DeadSessionError:
219
+ print("Session has died - reconnection required")
220
+ except AttpException as e:
221
+ print(f"ATTP error: {e}")
222
+ ```
223
+
224
+ ## Requirements
225
+
226
+ - Python 3.11 - 3.13
227
+ - Dependencies:
228
+ - `pydantic` (>=2.11.7,<3.0.0)
229
+ - `attp-core` (==0.1.10)
230
+ - `msgpack` (>=1.1.1,<2.0.0)
231
+ - `ascender-framework` (>=2.0rc7,<3.0)
232
+
233
+ ## Development
234
+
235
+ ### Setup
236
+
237
+ ```bash
238
+ # Clone the repository
239
+ git clone https://github.com/AscenderTeam/attp-client.git
240
+ cd attp-client
241
+
242
+ # Install dependencies
243
+ poetry install
244
+
245
+ # Run tests
246
+ python -m pytest tests/
247
+ ```
248
+
249
+ ### Project Structure
250
+
251
+ ```
252
+ src/
253
+ ├── attp_client/ # Main package
254
+ │ ├── client.py # Main client class
255
+ │ ├── inference.py # AI inference API
256
+ │ ├── tools.py # Tool management
257
+ │ ├── catalog.py # Catalog operations
258
+ │ ├── router.py # Message routing
259
+ │ ├── session.py # Session management
260
+ │ ├── errors/ # Exception classes
261
+ │ ├── interfaces/ # Protocol interfaces
262
+ │ ├── misc/ # Utilities
263
+ │ ├── types/ # Type definitions
264
+ │ └── utils/ # Helper utilities
265
+ └── tests/ # Test suite
266
+ ```
267
+
268
+ ## License
269
+
270
+ MIT License - see LICENSE file for details.
271
+
272
+ ## Contributing
273
+
274
+ Contributions are welcome! Please feel free to submit a Pull Request.
275
+
276
+ ## Support
277
+
278
+ For issues and questions, please use the GitHub Issues page or contact the Ascender Team.
@@ -0,0 +1,260 @@
1
+ # ATTP Client
2
+
3
+ A Python SDK client for interacting with AgentHub's ATTP (Agent Tool Transport Protocol).
4
+
5
+ ## Overview
6
+
7
+ The ATTP Client provides a comprehensive Python interface for connecting to and interacting with AgentHub's ATTP protocol. It enables real-time communication with AI agents, tool management, and inference operations through a high-performance async/await interface.
8
+
9
+ ## Features
10
+
11
+ - **Async/Await Support**: Built with modern Python async patterns for optimal performance
12
+ - **Agent Communication**: Direct communication with AI agents through the ATTP protocol
13
+ - **Tool Management**: Register, unregister, and manage tools in organized catalogs
14
+ - **Inference API**: Invoke AI agent inference with configurable parameters
15
+ - **Real-time Messaging**: Stream responses and handle real-time agent interactions
16
+ - **Event Handling**: Register custom event handlers for connect/disconnect and custom routes
17
+ - **Authentication**: Secure token-based authentication with organization support
18
+
19
+ ## Installation
20
+
21
+ ```bash
22
+ pip install attp-client
23
+ ```
24
+
25
+ Or with Poetry:
26
+
27
+ ```bash
28
+ poetry add attp-client
29
+ ```
30
+
31
+ ## Quick Start
32
+
33
+ ### Basic Connection
34
+
35
+ ```python
36
+ import asyncio
37
+ from attp_client.client import ATTPClient
38
+
39
+ async def main():
40
+ # Initialize the client
41
+ client = ATTPClient(
42
+ agt_token="your_agent_token_here",
43
+ organization_id=1,
44
+ connection_url="attp://localhost:6563" # Optional, defaults to localhost
45
+ )
46
+
47
+ # Connect to AgentHub
48
+ await client.connect()
49
+
50
+ # Your code here...
51
+
52
+ # Close the connection
53
+ await client.close()
54
+
55
+ if __name__ == "__main__":
56
+ asyncio.run(main())
57
+ ```
58
+
59
+ ### Agent Inference
60
+
61
+ ```python
62
+ from attp_client.interfaces.inference.message import IMessageDTOV2
63
+ from attp_client.interfaces.inference.enums.message_type import MessageTypeEnum
64
+ from uuid import UUID
65
+
66
+ # Invoke inference by agent ID
67
+ response = await client.inference.invoke_inference(
68
+ agent_id=17,
69
+ input_configuration={},
70
+ messages=[
71
+ IMessageDTOV2(
72
+ content="Hello, how can you help me?",
73
+ message_type=MessageTypeEnum.USER_MESSAGE,
74
+ chat_id=UUID("your-chat-id-here")
75
+ )
76
+ ],
77
+ stream=False,
78
+ timeout=30
79
+ )
80
+
81
+ print("Agent response:", response)
82
+ ```
83
+
84
+ ### Tool Management
85
+
86
+ ```python
87
+ # Register a tool
88
+ tool_id = await client.tools.register(
89
+ catalog_name="my_catalog",
90
+ name="example_tool",
91
+ description="An example tool for demonstration",
92
+ schema_id="tool_schema_v1",
93
+ return_direct=False,
94
+ timeout_ms=20000
95
+ )
96
+
97
+ # Access a specific catalog
98
+ catalog = await client.catalog("my_catalog")
99
+
100
+ # Unregister a tool
101
+ await client.tools.unregister("my_catalog", str(tool_id))
102
+ ```
103
+
104
+ ### Event Handling
105
+
106
+ ```python
107
+ def on_connect():
108
+ print("Connected to AgentHub!")
109
+
110
+ def on_disconnect():
111
+ print("Disconnected from AgentHub!")
112
+
113
+ def handle_custom_event(data):
114
+ print(f"Received custom event: {data}")
115
+
116
+ # Register event handlers
117
+ client.add_event_handler("", "connect", on_connect)
118
+ client.add_event_handler("", "disconnect", on_disconnect)
119
+ client.add_event_handler("custom:pattern", "custom", handle_custom_event)
120
+ ```
121
+
122
+ ## Configuration
123
+
124
+ ### Client Parameters
125
+
126
+ - `agt_token` (str): Your AgentHub authentication token
127
+ - `organization_id` (int): Your organization ID
128
+ - `connection_url` (str, optional): ATTP server URL (default: "attp://localhost:6563")
129
+ - `max_retries` (int, optional): Maximum connection retry attempts (default: 20)
130
+ - `limits` (Limits, optional): Connection limits configuration
131
+ - `logger` (Logger, optional): Custom logger instance
132
+
133
+ ### Connection Limits
134
+
135
+ ```python
136
+ from attp_core.rs_api import Limits
137
+
138
+ limits = Limits(max_payload_size=50000)
139
+ client = ATTPClient(
140
+ agt_token="...",
141
+ organization_id=1,
142
+ limits=limits
143
+ )
144
+ ```
145
+
146
+ ## API Reference
147
+
148
+ ### ATTPClient
149
+
150
+ The main client class for ATTP communication.
151
+
152
+ #### Methods
153
+
154
+ - `connect()`: Establish connection to AgentHub
155
+ - `close()`: Close the connection
156
+ - `catalog(catalog_name: str)`: Access a specific tool catalog
157
+ - `add_event_handler(pattern: str, route_type: RouteType, callback: Callable)`: Register event handlers
158
+
159
+ #### Properties
160
+
161
+ - `inference`: Access to the inference API
162
+ - `tools`: Access to the tools manager
163
+ - `router`: Access to the low-level router
164
+
165
+ ### AttpInferenceAPI
166
+
167
+ Handles AI agent inference operations.
168
+
169
+ #### Methods
170
+
171
+ - `invoke_inference()`: Invoke inference for a specific agent
172
+ - `invoke_chat_inference()`: Invoke inference for a chat session
173
+
174
+ ### ToolsManager
175
+
176
+ Manages tool registration and organization.
177
+
178
+ #### Methods
179
+
180
+ - `register()`: Register a new tool
181
+ - `unregister()`: Remove tool registration
182
+
183
+ ## Error Handling
184
+
185
+ The client includes comprehensive error handling:
186
+
187
+ ```python
188
+ from attp_client.errors import (
189
+ AttpException,
190
+ DeadSessionError,
191
+ NotFoundError,
192
+ SerializationError,
193
+ UnauthenticatedError
194
+ )
195
+
196
+ try:
197
+ await client.connect()
198
+ except UnauthenticatedError:
199
+ print("Authentication failed - check your token")
200
+ except DeadSessionError:
201
+ print("Session has died - reconnection required")
202
+ except AttpException as e:
203
+ print(f"ATTP error: {e}")
204
+ ```
205
+
206
+ ## Requirements
207
+
208
+ - Python 3.11 - 3.13
209
+ - Dependencies:
210
+ - `pydantic` (>=2.11.7,<3.0.0)
211
+ - `attp-core` (==0.1.10)
212
+ - `msgpack` (>=1.1.1,<2.0.0)
213
+ - `ascender-framework` (>=2.0rc7,<3.0)
214
+
215
+ ## Development
216
+
217
+ ### Setup
218
+
219
+ ```bash
220
+ # Clone the repository
221
+ git clone https://github.com/AscenderTeam/attp-client.git
222
+ cd attp-client
223
+
224
+ # Install dependencies
225
+ poetry install
226
+
227
+ # Run tests
228
+ python -m pytest tests/
229
+ ```
230
+
231
+ ### Project Structure
232
+
233
+ ```
234
+ src/
235
+ ├── attp_client/ # Main package
236
+ │ ├── client.py # Main client class
237
+ │ ├── inference.py # AI inference API
238
+ │ ├── tools.py # Tool management
239
+ │ ├── catalog.py # Catalog operations
240
+ │ ├── router.py # Message routing
241
+ │ ├── session.py # Session management
242
+ │ ├── errors/ # Exception classes
243
+ │ ├── interfaces/ # Protocol interfaces
244
+ │ ├── misc/ # Utilities
245
+ │ ├── types/ # Type definitions
246
+ │ └── utils/ # Helper utilities
247
+ └── tests/ # Test suite
248
+ ```
249
+
250
+ ## License
251
+
252
+ MIT License - see LICENSE file for details.
253
+
254
+ ## Contributing
255
+
256
+ Contributions are welcome! Please feel free to submit a Pull Request.
257
+
258
+ ## Support
259
+
260
+ For issues and questions, please use the GitHub Issues page or contact the Ascender Team.
@@ -0,0 +1,27 @@
1
+ [project]
2
+ name = "attp-client"
3
+ version = "0.0.1"
4
+ description = "A python-sdk client for interacting with AgentHub's ATTP protocol (Agent Tool Transport Protocol)"
5
+ authors = [
6
+ {name = "Ascender Team"}
7
+ ]
8
+ license = {text = "MIT"}
9
+ readme = "README.md"
10
+ requires-python = ">=3.11,<3.14"
11
+ dependencies = [
12
+ "pydantic (>=2.11.7,<3.0.0)",
13
+ "attp-core (==0.1.10)",
14
+ "msgpack (>=1.1.1,<2.0.0)",
15
+ "ascender-framework (>=2.0rc7,<3.0)"
16
+ ]
17
+
18
+ [tool.poetry]
19
+ package-mode = true
20
+ packages = [
21
+ { include = "attp_client", from = "src" }
22
+ ]
23
+
24
+
25
+ [build-system]
26
+ requires = ["poetry-core>=2.0.0,<3.0.0"]
27
+ build-backend = "poetry.core.masonry.api"
@@ -0,0 +1,59 @@
1
+ from typing import Any, Callable, MutableMapping
2
+ from attp_client.errors.not_found import NotFoundError
3
+ from attp_client.tools import ToolsManager
4
+
5
+
6
+ class AttpCatalog:
7
+ attached_tools: MutableMapping[str, Callable[..., Any]]
8
+ tool_name_to_id_symlink: MutableMapping[str, str]
9
+
10
+ def __init__(
11
+ self,
12
+ id: int,
13
+ catalog_name: str,
14
+ manager: ToolsManager
15
+ ) -> None:
16
+ self.id = id
17
+ self.catalog_name = catalog_name
18
+ self.tool_manager = manager
19
+ self.attached_tools = {}
20
+ self.tool_name_to_id_symlink = {}
21
+
22
+ async def attach_tool(
23
+ self,
24
+ callback: Callable[..., Any],
25
+ name: str,
26
+ description: str | None = None,
27
+ schema_id: str | None = None,
28
+ *,
29
+ return_direct: bool = False,
30
+ schema_ver: str = "1.0",
31
+ timeout_ms: float = 20000,
32
+ idempotent: bool = False
33
+ ):
34
+ assigned_id = await self.tool_manager.register(
35
+ self.catalog_name,
36
+ name=name,
37
+ description=description,
38
+ schema_id=schema_id,
39
+ return_direct=return_direct,
40
+ schema_ver=schema_ver,
41
+ timeout_ms=timeout_ms,
42
+ idempotent=idempotent
43
+ )
44
+
45
+ self.attached_tools[str(assigned_id)] = callback
46
+ self.tool_name_to_id_symlink[name] = str(assigned_id)
47
+ return assigned_id
48
+
49
+ async def detatch_tool(
50
+ self,
51
+ name: str
52
+ ):
53
+ tool_id = self.tool_name_to_id_symlink.get(name)
54
+
55
+ if not tool_id:
56
+ raise NotFoundError(f"Tool {name} not marked as registered and wasn't found in the catalog {self.catalog_name}.")
57
+
58
+ await self.tool_manager.unregister(self.catalog_name, tool_id)
59
+ return tool_id