solace-agent-mesh 1.0.7__py3-none-any.whl → 1.1.0__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 solace-agent-mesh might be problematic. Click here for more details.

Files changed (163) hide show
  1. solace_agent_mesh/agent/adk/adk_llm.txt +182 -42
  2. solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +171 -0
  3. solace_agent_mesh/agent/adk/callbacks.py +165 -104
  4. solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +0 -18
  5. solace_agent_mesh/agent/adk/models/models_llm.txt +104 -55
  6. solace_agent_mesh/agent/adk/runner.py +7 -5
  7. solace_agent_mesh/agent/adk/services.py +9 -1
  8. solace_agent_mesh/agent/adk/setup.py +11 -0
  9. solace_agent_mesh/agent/adk/stream_parser.py +8 -1
  10. solace_agent_mesh/agent/adk/tool_wrapper.py +10 -3
  11. solace_agent_mesh/agent/agent_llm.txt +355 -18
  12. solace_agent_mesh/agent/protocol/event_handlers.py +433 -296
  13. solace_agent_mesh/agent/protocol/protocol_llm.txt +54 -7
  14. solace_agent_mesh/agent/sac/app.py +1 -1
  15. solace_agent_mesh/agent/sac/component.py +212 -517
  16. solace_agent_mesh/agent/sac/sac_llm.txt +133 -63
  17. solace_agent_mesh/agent/testing/testing_llm.txt +25 -58
  18. solace_agent_mesh/agent/tools/peer_agent_tool.py +15 -11
  19. solace_agent_mesh/agent/tools/tools_llm.txt +234 -69
  20. solace_agent_mesh/agent/utils/artifact_helpers.py +35 -1
  21. solace_agent_mesh/agent/utils/utils_llm.txt +90 -105
  22. solace_agent_mesh/assets/docs/404.html +3 -3
  23. solace_agent_mesh/assets/docs/assets/js/{3d406171.7d02a73b.js → 3d406171.0b9eeed1.js} +1 -1
  24. solace_agent_mesh/assets/docs/assets/js/6e0db977.39a79ca9.js +1 -0
  25. solace_agent_mesh/assets/docs/assets/js/{75384d09.ccd480c4.js → 75384d09.bf78fbdb.js} +1 -1
  26. solace_agent_mesh/assets/docs/assets/js/90dd9cf6.88f385ea.js +1 -0
  27. solace_agent_mesh/assets/docs/assets/js/f284c35a.fb68323a.js +1 -0
  28. solace_agent_mesh/assets/docs/assets/js/main.a75ecc0d.js +2 -0
  29. solace_agent_mesh/assets/docs/assets/js/runtime~main.458efb1d.js +1 -0
  30. solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +4 -4
  31. solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +4 -4
  32. solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +4 -4
  33. solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +4 -4
  34. solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +4 -4
  35. solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +4 -4
  36. solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +4 -4
  37. solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +4 -4
  38. solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +4 -4
  39. solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +4 -4
  40. solace_agent_mesh/assets/docs/docs/documentation/getting-started/configurations/index.html +4 -4
  41. solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +4 -4
  42. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +4 -4
  43. solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +4 -4
  44. solace_agent_mesh/assets/docs/docs/documentation/migration-guides/a2a-upgrade-to-0.3.0/a2a-gateway-upgrade-to-0.3.0/index.html +105 -0
  45. solace_agent_mesh/assets/docs/docs/documentation/migration-guides/a2a-upgrade-to-0.3.0/a2a-technical-migration-map/index.html +53 -0
  46. solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +4 -4
  47. solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +8 -8
  48. solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +4 -4
  49. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +4 -4
  50. solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +4 -4
  51. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rag-integration/index.html +4 -4
  52. solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +4 -4
  53. solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +4 -4
  54. solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +4 -4
  55. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +4 -4
  56. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +4 -4
  57. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +4 -4
  58. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +4 -4
  59. solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +4 -4
  60. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +4 -4
  61. solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +4 -4
  62. solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +4 -4
  63. solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +4 -4
  64. solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +4 -4
  65. solace_agent_mesh/assets/docs/lunr-index-1756992446316.json +1 -0
  66. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  67. solace_agent_mesh/assets/docs/search-doc-1756992446316.json +1 -0
  68. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  69. solace_agent_mesh/assets/docs/sitemap.xml +1 -1
  70. solace_agent_mesh/cli/__init__.py +1 -1
  71. solace_agent_mesh/cli/commands/add_cmd/web_add_agent_step.py +12 -3
  72. solace_agent_mesh/cli/commands/add_cmd/web_add_gateway_step.py +10 -14
  73. solace_agent_mesh/cli/commands/init_cmd/web_init_step.py +2 -15
  74. solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +6 -2
  75. solace_agent_mesh/cli/utils.py +15 -0
  76. solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-DvlO62me.js → authCallback-BmF2l6vg.js} +1 -1
  77. solace_agent_mesh/client/webui/frontend/static/assets/{client-bp6u3qVZ.js → client-D881Dttc.js} +4 -4
  78. solace_agent_mesh/client/webui/frontend/static/assets/main-C0jZjYa8.js +699 -0
  79. solace_agent_mesh/client/webui/frontend/static/assets/main-CCeG324-.css +1 -0
  80. solace_agent_mesh/client/webui/frontend/static/auth-callback.html +2 -2
  81. solace_agent_mesh/client/webui/frontend/static/index.html +3 -3
  82. solace_agent_mesh/common/a2a/__init__.py +213 -0
  83. solace_agent_mesh/common/a2a/a2a_llm.txt +182 -0
  84. solace_agent_mesh/common/a2a/artifact.py +328 -0
  85. solace_agent_mesh/common/a2a/events.py +183 -0
  86. solace_agent_mesh/common/a2a/message.py +307 -0
  87. solace_agent_mesh/common/a2a/protocol.py +513 -0
  88. solace_agent_mesh/common/a2a/task.py +127 -0
  89. solace_agent_mesh/common/a2a/translation.py +653 -0
  90. solace_agent_mesh/common/a2a/types.py +54 -0
  91. solace_agent_mesh/common/a2a_spec/a2a.json +2576 -0
  92. solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +407 -0
  93. solace_agent_mesh/common/a2a_spec/schemas/agent_progress_update.json +18 -0
  94. solace_agent_mesh/common/a2a_spec/schemas/artifact_creation_progress.json +31 -0
  95. solace_agent_mesh/common/a2a_spec/schemas/llm_invocation.json +18 -0
  96. solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +235 -0
  97. solace_agent_mesh/common/a2a_spec/schemas/tool_invocation_start.json +26 -0
  98. solace_agent_mesh/common/a2a_spec/schemas/tool_result.json +25 -0
  99. solace_agent_mesh/common/agent_registry.py +1 -1
  100. solace_agent_mesh/common/common_llm.txt +192 -70
  101. solace_agent_mesh/common/data_parts.py +99 -0
  102. solace_agent_mesh/common/middleware/middleware_llm.txt +17 -17
  103. solace_agent_mesh/common/sac/__init__.py +0 -0
  104. solace_agent_mesh/common/sac/sac_llm.txt +71 -0
  105. solace_agent_mesh/common/sac/sam_component_base.py +252 -0
  106. solace_agent_mesh/common/services/providers/providers_llm.txt +51 -84
  107. solace_agent_mesh/common/services/services_llm.txt +206 -26
  108. solace_agent_mesh/common/utils/artifact_utils.py +29 -0
  109. solace_agent_mesh/common/utils/embeds/embeds_llm.txt +176 -80
  110. solace_agent_mesh/common/utils/utils_llm.txt +323 -42
  111. solace_agent_mesh/config_portal/backend/common.py +1 -1
  112. solace_agent_mesh/config_portal/frontend/static/client/assets/{_index-MqsrTd6g.js → _index-Bym6YkMd.js} +74 -24
  113. solace_agent_mesh/config_portal/frontend/static/client/assets/{components-B7lKcHVY.js → components-Rk0n-9cK.js} +1 -1
  114. solace_agent_mesh/config_portal/frontend/static/client/assets/{entry.client-CEumGClk.js → entry.client-mvZjNKiz.js} +1 -1
  115. solace_agent_mesh/config_portal/frontend/static/client/assets/{index-DSo1AH_7.js → index-DzNKzXrc.js} +1 -1
  116. solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-d845808d.js +1 -0
  117. solace_agent_mesh/config_portal/frontend/static/client/assets/{root-C4XmHinv.js → root-BWvk5-gF.js} +1 -1
  118. solace_agent_mesh/config_portal/frontend/static/client/index.html +3 -3
  119. solace_agent_mesh/core_a2a/core_a2a_llm.txt +10 -8
  120. solace_agent_mesh/core_a2a/service.py +20 -44
  121. solace_agent_mesh/gateway/base/app.py +27 -1
  122. solace_agent_mesh/gateway/base/base_llm.txt +177 -72
  123. solace_agent_mesh/gateway/base/component.py +294 -523
  124. solace_agent_mesh/gateway/gateway_llm.txt +299 -58
  125. solace_agent_mesh/gateway/http_sse/component.py +156 -183
  126. solace_agent_mesh/gateway/http_sse/components/components_llm.txt +29 -29
  127. solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +272 -36
  128. solace_agent_mesh/gateway/http_sse/main.py +8 -10
  129. solace_agent_mesh/gateway/http_sse/routers/agents.py +1 -1
  130. solace_agent_mesh/gateway/http_sse/routers/artifacts.py +18 -4
  131. solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +231 -5
  132. solace_agent_mesh/gateway/http_sse/routers/sessions.py +12 -7
  133. solace_agent_mesh/gateway/http_sse/routers/tasks.py +116 -169
  134. solace_agent_mesh/gateway/http_sse/services/agent_service.py +1 -1
  135. solace_agent_mesh/gateway/http_sse/services/services_llm.txt +89 -135
  136. solace_agent_mesh/gateway/http_sse/services/task_service.py +2 -5
  137. solace_agent_mesh/solace_agent_mesh_llm.txt +362 -0
  138. solace_agent_mesh/templates/gateway_component_template.py +149 -98
  139. {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/METADATA +5 -4
  140. {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/RECORD +144 -127
  141. solace_agent_mesh/assets/docs/assets/js/f284c35a.731836ad.js +0 -1
  142. solace_agent_mesh/assets/docs/assets/js/main.d79f063b.js +0 -2
  143. solace_agent_mesh/assets/docs/assets/js/runtime~main.6415ad00.js +0 -1
  144. solace_agent_mesh/assets/docs/lunr-index-1756146501924.json +0 -1
  145. solace_agent_mesh/assets/docs/search-doc-1756146501924.json +0 -1
  146. solace_agent_mesh/client/webui/frontend/static/assets/main-BCpII1-0.css +0 -1
  147. solace_agent_mesh/client/webui/frontend/static/assets/main-BucUdn9m.js +0 -673
  148. solace_agent_mesh/common/a2a_protocol.py +0 -564
  149. solace_agent_mesh/common/client/__init__.py +0 -4
  150. solace_agent_mesh/common/client/card_resolver.py +0 -21
  151. solace_agent_mesh/common/client/client.py +0 -85
  152. solace_agent_mesh/common/client/client_llm.txt +0 -133
  153. solace_agent_mesh/common/server/__init__.py +0 -4
  154. solace_agent_mesh/common/server/server.py +0 -122
  155. solace_agent_mesh/common/server/server_llm.txt +0 -169
  156. solace_agent_mesh/common/server/task_manager.py +0 -291
  157. solace_agent_mesh/common/server/utils.py +0 -28
  158. solace_agent_mesh/common/types.py +0 -411
  159. solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-28271392.js +0 -1
  160. /solace_agent_mesh/assets/docs/assets/js/{main.d79f063b.js.LICENSE.txt → main.a75ecc0d.js.LICENSE.txt} +0 -0
  161. {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/WHEEL +0 -0
  162. {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/entry_points.txt +0 -0
  163. {solace_agent_mesh-1.0.7.dist-info → solace_agent_mesh-1.1.0.dist-info}/licenses/LICENSE +0 -0
@@ -1,291 +0,0 @@
1
- from abc import ABC, abstractmethod
2
- from typing import Union, AsyncIterable, List
3
- import asyncio
4
- from solace_ai_connector.common.log import log
5
- from ...common.types import (
6
- Task,
7
- JSONRPCResponse,
8
- TaskIdParams,
9
- TaskQueryParams,
10
- GetTaskRequest,
11
- TaskNotFoundError,
12
- SendTaskRequest,
13
- CancelTaskRequest,
14
- TaskNotCancelableError,
15
- SetTaskPushNotificationRequest,
16
- GetTaskPushNotificationRequest,
17
- GetTaskResponse,
18
- CancelTaskResponse,
19
- SendTaskResponse,
20
- SetTaskPushNotificationResponse,
21
- GetTaskPushNotificationResponse,
22
- TaskSendParams,
23
- TaskStatus,
24
- TaskState,
25
- TaskResubscriptionRequest,
26
- SendTaskStreamingRequest,
27
- SendTaskStreamingResponse,
28
- Artifact,
29
- PushNotificationConfig,
30
- TaskStatusUpdateEvent,
31
- JSONRPCError,
32
- TaskPushNotificationConfig,
33
- InternalError,
34
- )
35
- from ...common.server.utils import (
36
- new_not_implemented_error,
37
- )
38
-
39
-
40
- class TaskManager(ABC):
41
- @abstractmethod
42
- async def on_get_task(self, request: GetTaskRequest) -> GetTaskResponse:
43
- pass
44
-
45
- @abstractmethod
46
- async def on_cancel_task(self, request: CancelTaskRequest) -> CancelTaskResponse:
47
- pass
48
-
49
- @abstractmethod
50
- async def on_send_task(self, request: SendTaskRequest) -> SendTaskResponse:
51
- pass
52
-
53
- @abstractmethod
54
- async def on_send_task_subscribe(
55
- self, request: SendTaskStreamingRequest
56
- ) -> Union[AsyncIterable[SendTaskStreamingResponse], JSONRPCResponse]:
57
- pass
58
-
59
- @abstractmethod
60
- async def on_set_task_push_notification(
61
- self, request: SetTaskPushNotificationRequest
62
- ) -> SetTaskPushNotificationResponse:
63
- pass
64
-
65
- @abstractmethod
66
- async def on_get_task_push_notification(
67
- self, request: GetTaskPushNotificationRequest
68
- ) -> GetTaskPushNotificationResponse:
69
- pass
70
-
71
- @abstractmethod
72
- async def on_resubscribe_to_task(
73
- self, request: TaskResubscriptionRequest
74
- ) -> Union[AsyncIterable[SendTaskResponse], JSONRPCResponse]:
75
- pass
76
-
77
-
78
- class InMemoryTaskManager(TaskManager):
79
- def __init__(self):
80
- self.tasks: dict[str, Task] = {}
81
- self.push_notification_infos: dict[str, PushNotificationConfig] = {}
82
- self.lock = asyncio.Lock()
83
- self.task_sse_subscribers: dict[str, List[asyncio.Queue]] = {}
84
- self.subscriber_lock = asyncio.Lock()
85
-
86
- async def on_get_task(self, request: GetTaskRequest) -> GetTaskResponse:
87
- log.info("Getting task %s", request.params.id)
88
- task_query_params: TaskQueryParams = request.params
89
-
90
- async with self.lock:
91
- task = self.tasks.get(task_query_params.id)
92
- if task is None:
93
- return GetTaskResponse(id=request.id, error=TaskNotFoundError())
94
-
95
- task_result = self.append_task_history(
96
- task, task_query_params.historyLength
97
- )
98
-
99
- return GetTaskResponse(id=request.id, result=task_result)
100
-
101
- async def on_cancel_task(self, request: CancelTaskRequest) -> CancelTaskResponse:
102
- log.info("Cancelling task %s", request.params.id)
103
- task_id_params: TaskIdParams = request.params
104
-
105
- async with self.lock:
106
- task = self.tasks.get(task_id_params.id)
107
- if task is None:
108
- return CancelTaskResponse(id=request.id, error=TaskNotFoundError())
109
-
110
- return CancelTaskResponse(id=request.id, error=TaskNotCancelableError())
111
-
112
- @abstractmethod
113
- async def on_send_task(self, request: SendTaskRequest) -> SendTaskResponse:
114
- pass
115
-
116
- @abstractmethod
117
- async def on_send_task_subscribe(
118
- self, request: SendTaskStreamingRequest
119
- ) -> Union[AsyncIterable[SendTaskStreamingResponse], JSONRPCResponse]:
120
- pass
121
-
122
- async def set_push_notification_info(
123
- self, task_id: str, notification_config: PushNotificationConfig
124
- ):
125
- async with self.lock:
126
- task = self.tasks.get(task_id)
127
- if task is None:
128
- raise ValueError("Task not found for %s" % task_id)
129
-
130
- self.push_notification_infos[task_id] = notification_config
131
-
132
- return
133
-
134
- async def get_push_notification_info(self, task_id: str) -> PushNotificationConfig:
135
- async with self.lock:
136
- task = self.tasks.get(task_id)
137
- if task is None:
138
- raise ValueError("Task not found for %s" % task_id)
139
-
140
- return self.push_notification_infos[task_id]
141
-
142
- return
143
-
144
- async def has_push_notification_info(self, task_id: str) -> bool:
145
- async with self.lock:
146
- return task_id in self.push_notification_infos
147
-
148
- async def on_set_task_push_notification(
149
- self, request: SetTaskPushNotificationRequest
150
- ) -> SetTaskPushNotificationResponse:
151
- log.info("Setting task push notification %s", request.params.id)
152
- task_notification_params: TaskPushNotificationConfig = request.params
153
-
154
- try:
155
- await self.set_push_notification_info(
156
- task_notification_params.id,
157
- task_notification_params.pushNotificationConfig,
158
- )
159
- except Exception as e:
160
- log.error(
161
- "Error while setting push notification info: %s", e, exc_info=True
162
- )
163
- return JSONRPCResponse(
164
- id=request.id,
165
- error=InternalError(
166
- message="An error occurred while setting push notification info"
167
- ),
168
- )
169
-
170
- return SetTaskPushNotificationResponse(
171
- id=request.id, result=task_notification_params
172
- )
173
-
174
- async def on_get_task_push_notification(
175
- self, request: GetTaskPushNotificationRequest
176
- ) -> GetTaskPushNotificationResponse:
177
- log.info("Getting task push notification %s", request.params.id)
178
- task_params: TaskIdParams = request.params
179
-
180
- try:
181
- notification_info = await self.get_push_notification_info(task_params.id)
182
- except Exception as e:
183
- log.error(
184
- "Error while getting push notification info: %s", e, exc_info=True
185
- )
186
- return GetTaskPushNotificationResponse(
187
- id=request.id,
188
- error=InternalError(
189
- message="An error occurred while getting push notification info"
190
- ),
191
- )
192
-
193
- return GetTaskPushNotificationResponse(
194
- id=request.id,
195
- result=TaskPushNotificationConfig(
196
- id=task_params.id, pushNotificationConfig=notification_info
197
- ),
198
- )
199
-
200
- async def upsert_task(self, task_send_params: TaskSendParams) -> Task:
201
- log.info("Upserting task %s", task_send_params.id)
202
- async with self.lock:
203
- task = self.tasks.get(task_send_params.id)
204
- if task is None:
205
- task = Task(
206
- id=task_send_params.id,
207
- sessionId=task_send_params.sessionId,
208
- messages=[task_send_params.message],
209
- status=TaskStatus(state=TaskState.SUBMITTED),
210
- history=[task_send_params.message],
211
- )
212
- self.tasks[task_send_params.id] = task
213
- else:
214
- task.history.append(task_send_params.message)
215
-
216
- return task
217
-
218
- async def on_resubscribe_to_task(
219
- self, request: TaskResubscriptionRequest
220
- ) -> Union[AsyncIterable[SendTaskStreamingResponse], JSONRPCResponse]:
221
- return new_not_implemented_error(request.id)
222
-
223
- async def update_store(
224
- self, task_id: str, status: TaskStatus, artifacts: list[Artifact]
225
- ) -> Task:
226
- async with self.lock:
227
- try:
228
- task = self.tasks[task_id]
229
- except KeyError:
230
- log.error("Task %s not found for updating the task", task_id)
231
- raise ValueError("Task %s not found" % task_id)
232
-
233
- task.status = status
234
-
235
- if status.message is not None:
236
- task.history.append(status.message)
237
-
238
- if artifacts is not None:
239
- if task.artifacts is None:
240
- task.artifacts = []
241
- task.artifacts.extend(artifacts)
242
-
243
- return task
244
-
245
- def append_task_history(self, task: Task, historyLength: int | None):
246
- new_task = task.model_copy()
247
- if historyLength is not None and historyLength > 0:
248
- new_task.history = new_task.history[-historyLength:]
249
- else:
250
- new_task.history = []
251
-
252
- return new_task
253
-
254
- async def setup_sse_consumer(self, task_id: str, is_resubscribe: bool = False):
255
- async with self.subscriber_lock:
256
- if task_id not in self.task_sse_subscribers:
257
- if is_resubscribe:
258
- raise ValueError("Task not found for resubscription")
259
- else:
260
- self.task_sse_subscribers[task_id] = []
261
-
262
- sse_event_queue = asyncio.Queue(maxsize=0) # <=0 is unlimited
263
- self.task_sse_subscribers[task_id].append(sse_event_queue)
264
- return sse_event_queue
265
-
266
- async def enqueue_events_for_sse(self, task_id, task_update_event):
267
- async with self.subscriber_lock:
268
- if task_id not in self.task_sse_subscribers:
269
- return
270
-
271
- current_subscribers = self.task_sse_subscribers[task_id]
272
- for subscriber in current_subscribers:
273
- await subscriber.put(task_update_event)
274
-
275
- async def dequeue_events_for_sse(
276
- self, request_id, task_id, sse_event_queue: asyncio.Queue
277
- ) -> AsyncIterable[SendTaskStreamingResponse] | JSONRPCResponse:
278
- try:
279
- while True:
280
- event = await sse_event_queue.get()
281
- if isinstance(event, JSONRPCError):
282
- yield SendTaskStreamingResponse(id=request_id, error=event)
283
- break
284
-
285
- yield SendTaskStreamingResponse(id=request_id, result=event)
286
- if isinstance(event, TaskStatusUpdateEvent) and event.final:
287
- break
288
- finally:
289
- async with self.subscriber_lock:
290
- if task_id in self.task_sse_subscribers:
291
- self.task_sse_subscribers[task_id].remove(sse_event_queue)
@@ -1,28 +0,0 @@
1
- from ...common.types import (
2
- JSONRPCResponse,
3
- ContentTypeNotSupportedError,
4
- UnsupportedOperationError,
5
- )
6
- from typing import List
7
-
8
-
9
- def are_modalities_compatible(
10
- server_output_modes: List[str], client_output_modes: List[str]
11
- ):
12
- """Modalities are compatible if they are both non-empty
13
- and there is at least one common element."""
14
- if client_output_modes is None or len(client_output_modes) == 0:
15
- return True
16
-
17
- if server_output_modes is None or len(server_output_modes) == 0:
18
- return True
19
-
20
- return any(x in server_output_modes for x in client_output_modes)
21
-
22
-
23
- def new_incompatible_types_error(request_id):
24
- return JSONRPCResponse(id=request_id, error=ContentTypeNotSupportedError())
25
-
26
-
27
- def new_not_implemented_error(request_id):
28
- return JSONRPCResponse(id=request_id, error=UnsupportedOperationError())