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

Files changed (447) hide show
  1. solace_agent_mesh/agent/adk/alembic/README +74 -0
  2. solace_agent_mesh/agent/adk/alembic/env.py +77 -0
  3. solace_agent_mesh/agent/adk/alembic/script.py.mako +28 -0
  4. solace_agent_mesh/agent/adk/alembic/versions/e2902798564d_adk_session_db_upgrade.py +52 -0
  5. solace_agent_mesh/agent/adk/alembic.ini +112 -0
  6. solace_agent_mesh/agent/adk/artifacts/filesystem_artifact_service.py +164 -0
  7. solace_agent_mesh/agent/adk/artifacts/s3_artifact_service.py +163 -0
  8. solace_agent_mesh/agent/adk/callbacks.py +752 -127
  9. solace_agent_mesh/agent/adk/embed_resolving_mcp_toolset.py +99 -7
  10. solace_agent_mesh/agent/adk/intelligent_mcp_callbacks.py +52 -5
  11. solace_agent_mesh/agent/adk/mcp_content_processor.py +1 -1
  12. solace_agent_mesh/agent/adk/models/lite_llm.py +34 -16
  13. solace_agent_mesh/agent/adk/models/oauth2_token_manager.py +24 -137
  14. solace_agent_mesh/agent/adk/runner.py +66 -8
  15. solace_agent_mesh/agent/adk/schema_migration.py +88 -0
  16. solace_agent_mesh/agent/adk/services.py +41 -1
  17. solace_agent_mesh/agent/adk/setup.py +220 -32
  18. solace_agent_mesh/agent/adk/stream_parser.py +229 -40
  19. solace_agent_mesh/agent/protocol/event_handlers.py +219 -33
  20. solace_agent_mesh/agent/proxies/a2a/component.py +572 -75
  21. solace_agent_mesh/agent/proxies/a2a/config.py +80 -4
  22. solace_agent_mesh/agent/proxies/base/component.py +188 -22
  23. solace_agent_mesh/agent/proxies/base/proxy_task_context.py +3 -1
  24. solace_agent_mesh/agent/sac/app.py +37 -12
  25. solace_agent_mesh/agent/sac/component.py +322 -52
  26. solace_agent_mesh/agent/sac/patch_adk.py +8 -16
  27. solace_agent_mesh/agent/sac/task_execution_context.py +90 -0
  28. solace_agent_mesh/agent/tools/__init__.py +3 -0
  29. solace_agent_mesh/agent/tools/audio_tools.py +3 -3
  30. solace_agent_mesh/agent/tools/builtin_artifact_tools.py +698 -24
  31. solace_agent_mesh/agent/tools/deep_research_tools.py +2161 -0
  32. solace_agent_mesh/agent/tools/peer_agent_tool.py +82 -15
  33. solace_agent_mesh/agent/tools/time_tools.py +126 -0
  34. solace_agent_mesh/agent/tools/tool_config_types.py +54 -2
  35. solace_agent_mesh/agent/tools/web_search_tools.py +279 -0
  36. solace_agent_mesh/agent/tools/web_tools.py +125 -17
  37. solace_agent_mesh/agent/utils/artifact_helpers.py +243 -5
  38. solace_agent_mesh/agent/utils/context_helpers.py +17 -0
  39. solace_agent_mesh/assets/docs/404.html +6 -6
  40. solace_agent_mesh/assets/docs/assets/css/{styles.906a1503.css → styles.8162edfb.css} +1 -1
  41. solace_agent_mesh/assets/docs/assets/js/05749d90.19ac4f35.js +1 -0
  42. solace_agent_mesh/assets/docs/assets/js/15ba94aa.e186750d.js +1 -0
  43. solace_agent_mesh/assets/docs/assets/js/15e40e79.434bb30f.js +1 -0
  44. solace_agent_mesh/assets/docs/assets/js/17896441.e612dfb4.js +1 -0
  45. solace_agent_mesh/assets/docs/assets/js/2279.550aa580.js +2 -0
  46. solace_agent_mesh/assets/docs/assets/js/{17896441.a5e82f9b.js.LICENSE.txt → 2279.550aa580.js.LICENSE.txt} +6 -0
  47. solace_agent_mesh/assets/docs/assets/js/240a0364.83e37aa8.js +1 -0
  48. solace_agent_mesh/assets/docs/assets/js/2e32b5e0.2f0db237.js +1 -0
  49. solace_agent_mesh/assets/docs/assets/js/3a6c6137.7e61915d.js +1 -0
  50. solace_agent_mesh/assets/docs/assets/js/3ac1795d.7f7ab1c1.js +1 -0
  51. solace_agent_mesh/assets/docs/assets/js/3ff0015d.e53c9b78.js +1 -0
  52. solace_agent_mesh/assets/docs/assets/js/41adc471.0e95b87c.js +1 -0
  53. solace_agent_mesh/assets/docs/assets/js/4667dc50.bf2ad456.js +1 -0
  54. solace_agent_mesh/assets/docs/assets/js/49eed117.493d6f99.js +1 -0
  55. solace_agent_mesh/assets/docs/assets/js/{509e993c.4c7a1a6d.js → 509e993c.a1fbf45a.js} +1 -1
  56. solace_agent_mesh/assets/docs/assets/js/547e15cc.8e6da617.js +1 -0
  57. solace_agent_mesh/assets/docs/assets/js/55b7b518.29d6e75d.js +1 -0
  58. solace_agent_mesh/assets/docs/assets/js/5b8d9c11.d4eb37b8.js +1 -0
  59. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.1ee87753.js +1 -0
  60. solace_agent_mesh/assets/docs/assets/js/60702c0e.a8bdd79b.js +1 -0
  61. solace_agent_mesh/assets/docs/assets/js/64195356.09dbd087.js +1 -0
  62. solace_agent_mesh/assets/docs/assets/js/66d4869e.30340bd3.js +1 -0
  63. solace_agent_mesh/assets/docs/assets/js/6aaedf65.7253541d.js +1 -0
  64. solace_agent_mesh/assets/docs/assets/js/6d84eae0.fd23ba4a.js +1 -0
  65. solace_agent_mesh/assets/docs/assets/js/729898df.7249e9fd.js +1 -0
  66. solace_agent_mesh/assets/docs/assets/js/7e294c01.7c5f6906.js +1 -0
  67. solace_agent_mesh/assets/docs/assets/js/8024126c.e3467286.js +1 -0
  68. solace_agent_mesh/assets/docs/assets/js/81a99df0.7ed65d45.js +1 -0
  69. solace_agent_mesh/assets/docs/assets/js/82fbfb93.161823a5.js +1 -0
  70. solace_agent_mesh/assets/docs/assets/js/924ffdeb.975e428a.js +1 -0
  71. solace_agent_mesh/assets/docs/assets/js/94e8668d.16083b3f.js +1 -0
  72. solace_agent_mesh/assets/docs/assets/js/9bb13469.4523ae20.js +1 -0
  73. solace_agent_mesh/assets/docs/assets/js/a7d42657.a956689d.js +1 -0
  74. solace_agent_mesh/assets/docs/assets/js/a94703ab.3e5fbcb3.js +1 -0
  75. solace_agent_mesh/assets/docs/assets/js/ab9708a8.3e563275.js +1 -0
  76. solace_agent_mesh/assets/docs/assets/js/c93cbaa0.0e0d8baf.js +1 -0
  77. solace_agent_mesh/assets/docs/assets/js/cab03b5b.6a073091.js +1 -0
  78. solace_agent_mesh/assets/docs/assets/js/cbe2e9ea.07e170dd.js +1 -0
  79. solace_agent_mesh/assets/docs/assets/js/e04b235d.06d23db6.js +1 -0
  80. solace_agent_mesh/assets/docs/assets/js/e1b6eeb4.deb2b62e.js +1 -0
  81. solace_agent_mesh/assets/docs/assets/js/e3d9abda.1476f570.js +1 -0
  82. solace_agent_mesh/assets/docs/assets/js/e6f9706b.acc800d3.js +1 -0
  83. solace_agent_mesh/assets/docs/assets/js/e92d0134.c147a429.js +1 -0
  84. solace_agent_mesh/assets/docs/assets/js/ee0c2fe7.94d0a351.js +1 -0
  85. solace_agent_mesh/assets/docs/assets/js/f284c35a.cc97854c.js +1 -0
  86. solace_agent_mesh/assets/docs/assets/js/main.d634009f.js +2 -0
  87. solace_agent_mesh/assets/docs/assets/js/runtime~main.27bb82a7.js +1 -0
  88. solace_agent_mesh/assets/docs/docs/documentation/components/agents/index.html +68 -68
  89. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/artifact-management/index.html +50 -50
  90. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/audio-tools/index.html +42 -42
  91. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/data-analysis-tools/index.html +55 -55
  92. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/embeds/index.html +75 -75
  93. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/image-tools/index.html +81 -0
  94. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/index.html +67 -50
  95. solace_agent_mesh/assets/docs/docs/documentation/components/builtin-tools/research-tools/index.html +136 -0
  96. solace_agent_mesh/assets/docs/docs/documentation/components/cli/index.html +178 -144
  97. solace_agent_mesh/assets/docs/docs/documentation/components/gateways/index.html +43 -42
  98. solace_agent_mesh/assets/docs/docs/documentation/components/index.html +20 -18
  99. solace_agent_mesh/assets/docs/docs/documentation/components/orchestrator/index.html +23 -23
  100. solace_agent_mesh/assets/docs/docs/documentation/components/platform-service/index.html +33 -0
  101. solace_agent_mesh/assets/docs/docs/documentation/components/plugins/index.html +45 -45
  102. solace_agent_mesh/assets/docs/docs/documentation/components/projects/index.html +98 -112
  103. solace_agent_mesh/assets/docs/docs/documentation/components/prompts/index.html +147 -0
  104. solace_agent_mesh/assets/docs/docs/documentation/components/proxies/index.html +208 -125
  105. solace_agent_mesh/assets/docs/docs/documentation/components/speech/index.html +52 -0
  106. solace_agent_mesh/assets/docs/docs/documentation/deploying/debugging/index.html +28 -28
  107. solace_agent_mesh/assets/docs/docs/documentation/deploying/deployment-options/index.html +29 -29
  108. solace_agent_mesh/assets/docs/docs/documentation/deploying/index.html +14 -14
  109. solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes/index.html +47 -0
  110. solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes/kubernetes-deployment-guide/index.html +197 -0
  111. solace_agent_mesh/assets/docs/docs/documentation/deploying/logging/index.html +67 -53
  112. solace_agent_mesh/assets/docs/docs/documentation/deploying/observability/index.html +17 -17
  113. solace_agent_mesh/assets/docs/docs/documentation/deploying/proxy_configuration/index.html +49 -0
  114. solace_agent_mesh/assets/docs/docs/documentation/developing/create-agents/index.html +38 -38
  115. solace_agent_mesh/assets/docs/docs/documentation/developing/create-gateways/index.html +87 -87
  116. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-python-tools/index.html +67 -49
  117. solace_agent_mesh/assets/docs/docs/documentation/developing/creating-service-providers/index.html +17 -17
  118. solace_agent_mesh/assets/docs/docs/documentation/developing/evaluations/index.html +51 -51
  119. solace_agent_mesh/assets/docs/docs/documentation/developing/index.html +22 -22
  120. solace_agent_mesh/assets/docs/docs/documentation/developing/structure/index.html +27 -27
  121. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/bedrock-agents/index.html +135 -135
  122. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/custom-agent/index.html +66 -66
  123. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/event-mesh-gateway/index.html +51 -51
  124. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mcp-integration/index.html +50 -38
  125. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/mongodb-integration/index.html +86 -86
  126. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rag-integration/index.html +51 -51
  127. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/rest-gateway/index.html +24 -24
  128. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/slack-integration/index.html +30 -30
  129. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/sql-database/index.html +44 -44
  130. solace_agent_mesh/assets/docs/docs/documentation/developing/tutorials/teams-integration/index.html +115 -0
  131. solace_agent_mesh/assets/docs/docs/documentation/enterprise/agent-builder/index.html +50 -23
  132. solace_agent_mesh/assets/docs/docs/documentation/enterprise/connectors/index.html +29 -24
  133. solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +21 -21
  134. solace_agent_mesh/assets/docs/docs/documentation/enterprise/installation/index.html +40 -37
  135. solace_agent_mesh/assets/docs/docs/documentation/enterprise/openapi-tools/index.html +324 -0
  136. solace_agent_mesh/assets/docs/docs/documentation/enterprise/rbac-setup-guide/index.html +96 -66
  137. solace_agent_mesh/assets/docs/docs/documentation/enterprise/secure-user-delegated-access/index.html +181 -181
  138. solace_agent_mesh/assets/docs/docs/documentation/enterprise/single-sign-on/index.html +75 -75
  139. solace_agent_mesh/assets/docs/docs/documentation/enterprise/wheel-installation/index.html +27 -27
  140. solace_agent_mesh/assets/docs/docs/documentation/getting-started/architecture/index.html +44 -44
  141. solace_agent_mesh/assets/docs/docs/documentation/getting-started/index.html +39 -38
  142. solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +30 -30
  143. solace_agent_mesh/assets/docs/docs/documentation/getting-started/try-agent-mesh/index.html +18 -18
  144. solace_agent_mesh/assets/docs/docs/documentation/getting-started/vibe_coding/index.html +62 -0
  145. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/artifact-storage/index.html +135 -114
  146. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/configurations/index.html +37 -37
  147. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/index.html +14 -14
  148. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/installation/index.html +27 -25
  149. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/large_language_models/index.html +69 -69
  150. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/run-project/index.html +72 -72
  151. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/session-storage/index.html +112 -112
  152. solace_agent_mesh/assets/docs/docs/documentation/installing-and-configuring/user-feedback/index.html +28 -28
  153. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-gateway-upgrade-to-0.3.0/index.html +42 -42
  154. solace_agent_mesh/assets/docs/docs/documentation/migrations/a2a-upgrade/a2a-technical-migration-map/index.html +20 -20
  155. solace_agent_mesh/assets/docs/docs/documentation/migrations/platform-service-split/index.html +85 -0
  156. solace_agent_mesh/assets/docs/lunr-index-1768329217460.json +1 -0
  157. solace_agent_mesh/assets/docs/lunr-index.json +1 -1
  158. solace_agent_mesh/assets/docs/search-doc-1768329217460.json +1 -0
  159. solace_agent_mesh/assets/docs/search-doc.json +1 -1
  160. solace_agent_mesh/assets/docs/sitemap.xml +1 -1
  161. solace_agent_mesh/cli/__init__.py +1 -1
  162. solace_agent_mesh/cli/commands/add_cmd/__init__.py +3 -1
  163. solace_agent_mesh/cli/commands/add_cmd/agent_cmd.py +6 -1
  164. solace_agent_mesh/cli/commands/add_cmd/proxy_cmd.py +100 -0
  165. solace_agent_mesh/cli/commands/eval_cmd.py +1 -1
  166. solace_agent_mesh/cli/commands/init_cmd/__init__.py +15 -0
  167. solace_agent_mesh/cli/commands/init_cmd/directory_step.py +1 -1
  168. solace_agent_mesh/cli/commands/init_cmd/env_step.py +30 -3
  169. solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +3 -4
  170. solace_agent_mesh/cli/commands/init_cmd/platform_service_step.py +85 -0
  171. solace_agent_mesh/cli/commands/init_cmd/webui_gateway_step.py +16 -3
  172. solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +2 -1
  173. solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +1 -0
  174. solace_agent_mesh/cli/commands/plugin_cmd/create_cmd.py +3 -3
  175. solace_agent_mesh/cli/commands/run_cmd.py +64 -49
  176. solace_agent_mesh/cli/commands/tools_cmd.py +315 -0
  177. solace_agent_mesh/cli/main.py +15 -0
  178. solace_agent_mesh/client/webui/frontend/static/assets/{authCallback-tcIFZLis.js → authCallback-KnKMP_vb.js} +1 -1
  179. solace_agent_mesh/client/webui/frontend/static/assets/client-DpBL2stg.js +25 -0
  180. solace_agent_mesh/client/webui/frontend/static/assets/main-Cd498TV2.js +435 -0
  181. solace_agent_mesh/client/webui/frontend/static/assets/main-rSf8Vu29.css +1 -0
  182. solace_agent_mesh/client/webui/frontend/static/assets/{vendor-CINwxvwV.js → vendor-CGk8Suyh.js} +189 -94
  183. solace_agent_mesh/client/webui/frontend/static/auth-callback.html +3 -3
  184. solace_agent_mesh/client/webui/frontend/static/index.html +4 -4
  185. solace_agent_mesh/client/webui/frontend/static/mockServiceWorker.js +336 -0
  186. solace_agent_mesh/client/webui/frontend/static/ui-version.json +6 -0
  187. solace_agent_mesh/common/a2a/types.py +1 -1
  188. solace_agent_mesh/common/agent_registry.py +38 -11
  189. solace_agent_mesh/common/data_parts.py +124 -0
  190. solace_agent_mesh/common/error_handlers.py +83 -0
  191. solace_agent_mesh/common/exceptions.py +24 -0
  192. solace_agent_mesh/common/oauth/__init__.py +17 -0
  193. solace_agent_mesh/common/oauth/oauth_client.py +408 -0
  194. solace_agent_mesh/common/oauth/utils.py +50 -0
  195. solace_agent_mesh/common/rag_dto.py +156 -0
  196. solace_agent_mesh/common/sac/sam_component_base.py +73 -1
  197. solace_agent_mesh/common/sam_events/event_service.py +2 -2
  198. solace_agent_mesh/common/utils/embeds/converter.py +1 -8
  199. solace_agent_mesh/common/utils/embeds/modifiers.py +2 -27
  200. solace_agent_mesh/common/utils/embeds/resolver.py +94 -25
  201. solace_agent_mesh/common/utils/embeds/types.py +1 -0
  202. solace_agent_mesh/common/utils/log_formatters.py +20 -0
  203. solace_agent_mesh/common/utils/mime_helpers.py +12 -5
  204. solace_agent_mesh/common/utils/rbac_utils.py +69 -0
  205. solace_agent_mesh/common/utils/templates/__init__.py +8 -0
  206. solace_agent_mesh/common/utils/templates/liquid_renderer.py +210 -0
  207. solace_agent_mesh/common/utils/templates/template_resolver.py +161 -0
  208. solace_agent_mesh/config_portal/backend/common.py +12 -0
  209. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-CljP4_mv.js +103 -0
  210. solace_agent_mesh/config_portal/frontend/static/client/assets/{components-Rk0n-9cK.js → components-CaC6hG8d.js} +22 -22
  211. solace_agent_mesh/config_portal/frontend/static/client/assets/{entry.client-mvZjNKiz.js → entry.client-H_TM0YBt.js} +3 -3
  212. solace_agent_mesh/config_portal/frontend/static/client/assets/{index-DzNKzXrc.js → index-CnFykb2v.js} +16 -16
  213. solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-f8439d40.js +1 -0
  214. solace_agent_mesh/config_portal/frontend/static/client/assets/root-BIMqslJB.css +1 -0
  215. solace_agent_mesh/config_portal/frontend/static/client/assets/root-mJmTIdIk.js +10 -0
  216. solace_agent_mesh/config_portal/frontend/static/client/index.html +3 -3
  217. solace_agent_mesh/core_a2a/service.py +3 -2
  218. solace_agent_mesh/gateway/adapter/base.py +28 -1
  219. solace_agent_mesh/gateway/adapter/types.py +9 -0
  220. solace_agent_mesh/gateway/base/app.py +10 -0
  221. solace_agent_mesh/gateway/base/auth_interface.py +103 -0
  222. solace_agent_mesh/gateway/base/component.py +451 -10
  223. solace_agent_mesh/gateway/generic/component.py +274 -30
  224. solace_agent_mesh/gateway/http_sse/alembic/env.py +0 -7
  225. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_soft_delete_and_search.py +2 -43
  226. solace_agent_mesh/gateway/http_sse/alembic/versions/20251024_add_default_agent_to_projects.py +2 -2
  227. solace_agent_mesh/gateway/http_sse/alembic/versions/20251108_create_prompt_tables_with_sharing.py +154 -0
  228. solace_agent_mesh/gateway/http_sse/alembic/versions/20251115_add_parent_task_id.py +32 -0
  229. solace_agent_mesh/gateway/http_sse/alembic/versions/20251126_add_background_task_fields.py +47 -0
  230. solace_agent_mesh/gateway/http_sse/alembic/versions/20251202_add_versioned_fields_to_prompts.py +52 -0
  231. solace_agent_mesh/gateway/http_sse/alembic.ini +0 -36
  232. solace_agent_mesh/gateway/http_sse/app.py +23 -6
  233. solace_agent_mesh/gateway/http_sse/component.py +158 -73
  234. solace_agent_mesh/gateway/http_sse/dependencies.py +50 -57
  235. solace_agent_mesh/gateway/http_sse/main.py +58 -482
  236. solace_agent_mesh/gateway/http_sse/repository/chat_task_repository.py +2 -2
  237. solace_agent_mesh/gateway/http_sse/repository/entities/project.py +1 -1
  238. solace_agent_mesh/gateway/http_sse/repository/entities/project_user.py +1 -1
  239. solace_agent_mesh/gateway/http_sse/repository/entities/session.py +3 -2
  240. solace_agent_mesh/gateway/http_sse/repository/entities/task.py +7 -0
  241. solace_agent_mesh/gateway/http_sse/repository/feedback_repository.py +2 -2
  242. solace_agent_mesh/gateway/http_sse/repository/interfaces.py +2 -2
  243. solace_agent_mesh/gateway/http_sse/repository/models/__init__.py +5 -0
  244. solace_agent_mesh/gateway/http_sse/repository/models/prompt_model.py +159 -0
  245. solace_agent_mesh/gateway/http_sse/repository/models/session_model.py +1 -1
  246. solace_agent_mesh/gateway/http_sse/repository/models/task_model.py +8 -1
  247. solace_agent_mesh/gateway/http_sse/repository/project_repository.py +1 -1
  248. solace_agent_mesh/gateway/http_sse/repository/project_user_repository.py +1 -1
  249. solace_agent_mesh/gateway/http_sse/repository/session_repository.py +12 -107
  250. solace_agent_mesh/gateway/http_sse/repository/task_repository.py +86 -2
  251. solace_agent_mesh/gateway/http_sse/routers/agent_cards.py +38 -7
  252. solace_agent_mesh/gateway/http_sse/routers/artifacts.py +113 -7
  253. solace_agent_mesh/gateway/http_sse/routers/auth.py +69 -132
  254. solace_agent_mesh/gateway/http_sse/routers/config.py +235 -10
  255. solace_agent_mesh/gateway/http_sse/routers/dto/project_dto.py +69 -0
  256. solace_agent_mesh/gateway/http_sse/routers/dto/prompt_dto.py +255 -0
  257. solace_agent_mesh/gateway/http_sse/routers/dto/requests/session_requests.py +1 -1
  258. solace_agent_mesh/gateway/http_sse/routers/dto/responses/base_responses.py +1 -1
  259. solace_agent_mesh/gateway/http_sse/routers/dto/responses/project_responses.py +1 -0
  260. solace_agent_mesh/gateway/http_sse/routers/dto/responses/session_responses.py +3 -2
  261. solace_agent_mesh/gateway/http_sse/routers/dto/responses/version_responses.py +31 -0
  262. solace_agent_mesh/gateway/http_sse/routers/feedback.py +2 -2
  263. solace_agent_mesh/gateway/http_sse/routers/people.py +2 -2
  264. solace_agent_mesh/gateway/http_sse/routers/projects.py +250 -24
  265. solace_agent_mesh/gateway/http_sse/routers/prompts.py +1416 -0
  266. solace_agent_mesh/gateway/http_sse/routers/sessions.py +14 -5
  267. solace_agent_mesh/gateway/http_sse/routers/speech.py +355 -0
  268. solace_agent_mesh/gateway/http_sse/routers/sse.py +117 -4
  269. solace_agent_mesh/gateway/http_sse/routers/tasks.py +509 -149
  270. solace_agent_mesh/gateway/http_sse/routers/users.py +1 -1
  271. solace_agent_mesh/gateway/http_sse/routers/version.py +343 -0
  272. solace_agent_mesh/gateway/http_sse/routers/visualization.py +2 -1
  273. solace_agent_mesh/gateway/http_sse/services/audio_service.py +1227 -0
  274. solace_agent_mesh/gateway/http_sse/services/background_task_monitor.py +186 -0
  275. solace_agent_mesh/gateway/http_sse/services/data_retention_service.py +1 -1
  276. solace_agent_mesh/gateway/http_sse/services/feedback_service.py +1 -1
  277. solace_agent_mesh/gateway/http_sse/services/project_service.py +539 -12
  278. solace_agent_mesh/gateway/http_sse/services/prompt_builder_assistant.py +303 -0
  279. solace_agent_mesh/gateway/http_sse/services/session_service.py +198 -21
  280. solace_agent_mesh/gateway/http_sse/services/task_logger_service.py +354 -4
  281. solace_agent_mesh/gateway/http_sse/sse_manager.py +280 -169
  282. solace_agent_mesh/gateway/http_sse/utils/artifact_copy_utils.py +370 -0
  283. solace_agent_mesh/gateway/http_sse/utils/stim_utils.py +41 -1
  284. solace_agent_mesh/services/__init__.py +0 -0
  285. solace_agent_mesh/services/platform/__init__.py +29 -0
  286. solace_agent_mesh/services/platform/alembic/env.py +85 -0
  287. solace_agent_mesh/services/platform/alembic/script.py.mako +28 -0
  288. solace_agent_mesh/services/platform/alembic.ini +109 -0
  289. solace_agent_mesh/services/platform/api/__init__.py +3 -0
  290. solace_agent_mesh/services/platform/api/dependencies.py +154 -0
  291. solace_agent_mesh/services/platform/api/main.py +314 -0
  292. solace_agent_mesh/services/platform/api/middleware.py +51 -0
  293. solace_agent_mesh/services/platform/api/routers/__init__.py +33 -0
  294. solace_agent_mesh/services/platform/api/routers/health_router.py +31 -0
  295. solace_agent_mesh/services/platform/app.py +215 -0
  296. solace_agent_mesh/services/platform/component.py +777 -0
  297. solace_agent_mesh/shared/__init__.py +14 -0
  298. solace_agent_mesh/shared/api/__init__.py +42 -0
  299. solace_agent_mesh/shared/auth/__init__.py +26 -0
  300. solace_agent_mesh/shared/auth/dependencies.py +204 -0
  301. solace_agent_mesh/shared/auth/middleware.py +347 -0
  302. solace_agent_mesh/shared/database/__init__.py +20 -0
  303. solace_agent_mesh/{gateway/http_sse/shared → shared/database}/base_repository.py +1 -1
  304. solace_agent_mesh/{gateway/http_sse/shared → shared/database}/database_exceptions.py +1 -1
  305. solace_agent_mesh/{gateway/http_sse/shared → shared/database}/database_helpers.py +1 -1
  306. solace_agent_mesh/shared/exceptions/__init__.py +36 -0
  307. solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/exception_handlers.py +1 -1
  308. solace_agent_mesh/shared/utils/__init__.py +21 -0
  309. solace_agent_mesh/templates/logging_config_template.yaml +48 -0
  310. solace_agent_mesh/templates/main_orchestrator.yaml +12 -1
  311. solace_agent_mesh/templates/platform.yaml +49 -0
  312. solace_agent_mesh/templates/plugin_readme_template.md +3 -25
  313. solace_agent_mesh/templates/plugin_tool_config_template.yaml +109 -0
  314. solace_agent_mesh/templates/proxy_template.yaml +62 -0
  315. solace_agent_mesh/templates/webui.yaml +148 -6
  316. solace_agent_mesh/tools/web_search/__init__.py +18 -0
  317. solace_agent_mesh/tools/web_search/base.py +84 -0
  318. solace_agent_mesh/tools/web_search/google_search.py +247 -0
  319. solace_agent_mesh/tools/web_search/models.py +99 -0
  320. {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/METADATA +29 -8
  321. {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/RECORD +334 -313
  322. {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/WHEEL +1 -1
  323. solace_agent_mesh/agent/adk/adk_llm.txt +0 -226
  324. solace_agent_mesh/agent/adk/adk_llm_detail.txt +0 -566
  325. solace_agent_mesh/agent/adk/artifacts/artifacts_llm.txt +0 -171
  326. solace_agent_mesh/agent/adk/models/models_llm.txt +0 -189
  327. solace_agent_mesh/agent/agent_llm.txt +0 -369
  328. solace_agent_mesh/agent/agent_llm_detail.txt +0 -1702
  329. solace_agent_mesh/agent/protocol/protocol_llm.txt +0 -81
  330. solace_agent_mesh/agent/protocol/protocol_llm_detail.txt +0 -92
  331. solace_agent_mesh/agent/proxies/a2a/a2a_llm.txt +0 -190
  332. solace_agent_mesh/agent/proxies/base/base_llm.txt +0 -148
  333. solace_agent_mesh/agent/proxies/proxies_llm.txt +0 -283
  334. solace_agent_mesh/agent/sac/sac_llm.txt +0 -189
  335. solace_agent_mesh/agent/sac/sac_llm_detail.txt +0 -200
  336. solace_agent_mesh/agent/testing/testing_llm.txt +0 -58
  337. solace_agent_mesh/agent/testing/testing_llm_detail.txt +0 -68
  338. solace_agent_mesh/agent/tools/tools_llm.txt +0 -276
  339. solace_agent_mesh/agent/tools/tools_llm_detail.txt +0 -275
  340. solace_agent_mesh/agent/utils/utils_llm.txt +0 -152
  341. solace_agent_mesh/agent/utils/utils_llm_detail.txt +0 -149
  342. solace_agent_mesh/assets/docs/assets/js/05749d90.c70b2be9.js +0 -1
  343. solace_agent_mesh/assets/docs/assets/js/15ba94aa.92fea363.js +0 -1
  344. solace_agent_mesh/assets/docs/assets/js/15e40e79.36003774.js +0 -1
  345. solace_agent_mesh/assets/docs/assets/js/17896441.a5e82f9b.js +0 -2
  346. solace_agent_mesh/assets/docs/assets/js/240a0364.c39f8388.js +0 -1
  347. solace_agent_mesh/assets/docs/assets/js/2e32b5e0.33f5d75b.js +0 -1
  348. solace_agent_mesh/assets/docs/assets/js/3a6c6137.f5940cfa.js +0 -1
  349. solace_agent_mesh/assets/docs/assets/js/3ac1795d.e4870a49.js +0 -1
  350. solace_agent_mesh/assets/docs/assets/js/3ff0015d.b63ee53a.js +0 -1
  351. solace_agent_mesh/assets/docs/assets/js/547e15cc.2f7790c1.js +0 -1
  352. solace_agent_mesh/assets/docs/assets/js/55b7b518.f2b1d1ba.js +0 -1
  353. solace_agent_mesh/assets/docs/assets/js/5c2bd65f.45b32c2b.js +0 -1
  354. solace_agent_mesh/assets/docs/assets/js/64195356.c498c4d0.js +0 -1
  355. solace_agent_mesh/assets/docs/assets/js/66d4869e.830d443f.js +0 -1
  356. solace_agent_mesh/assets/docs/assets/js/6d84eae0.4a5fbf39.js +0 -1
  357. solace_agent_mesh/assets/docs/assets/js/8024126c.fa0e7186.js +0 -1
  358. solace_agent_mesh/assets/docs/assets/js/81a99df0.07034dd9.js +0 -1
  359. solace_agent_mesh/assets/docs/assets/js/82fbfb93.139a1a1f.js +0 -1
  360. solace_agent_mesh/assets/docs/assets/js/924ffdeb.8095e148.js +0 -1
  361. solace_agent_mesh/assets/docs/assets/js/94e8668d.09ed9234.js +0 -1
  362. solace_agent_mesh/assets/docs/assets/js/9bb13469.dd1c9b54.js +0 -1
  363. solace_agent_mesh/assets/docs/assets/js/a94703ab.0438dbc2.js +0 -1
  364. solace_agent_mesh/assets/docs/assets/js/ab9708a8.245ae0ef.js +0 -1
  365. solace_agent_mesh/assets/docs/assets/js/c93cbaa0.eaff365e.js +0 -1
  366. solace_agent_mesh/assets/docs/assets/js/cbe2e9ea.f902fad8.js +0 -1
  367. solace_agent_mesh/assets/docs/assets/js/db5d6442.3daf1696.js +0 -1
  368. solace_agent_mesh/assets/docs/assets/js/e04b235d.c9c50c7b.js +0 -1
  369. solace_agent_mesh/assets/docs/assets/js/e3d9abda.d11c67a7.js +0 -1
  370. solace_agent_mesh/assets/docs/assets/js/e6f9706b.045d0fa1.js +0 -1
  371. solace_agent_mesh/assets/docs/assets/js/e92d0134.3bda61dd.js +0 -1
  372. solace_agent_mesh/assets/docs/assets/js/f284c35a.5099c51e.js +0 -1
  373. solace_agent_mesh/assets/docs/assets/js/main.f213fe0c.js +0 -2
  374. solace_agent_mesh/assets/docs/assets/js/runtime~main.d9606d6a.js +0 -1
  375. solace_agent_mesh/assets/docs/docs/documentation/deploying/kubernetes-deployment/index.html +0 -47
  376. solace_agent_mesh/assets/docs/lunr-index-1762283454666.json +0 -1
  377. solace_agent_mesh/assets/docs/search-doc-1762283454666.json +0 -1
  378. solace_agent_mesh/cli/commands/add_cmd/add_cmd_llm.txt +0 -250
  379. solace_agent_mesh/cli/commands/init_cmd/init_cmd_llm.txt +0 -365
  380. solace_agent_mesh/cli/commands/plugin_cmd/plugin_cmd_llm.txt +0 -305
  381. solace_agent_mesh/client/webui/frontend/static/assets/client-CRYdKo2Q.js +0 -25
  382. solace_agent_mesh/client/webui/frontend/static/assets/main-CojeY_1w.css +0 -1
  383. solace_agent_mesh/client/webui/frontend/static/assets/main-ILja9MCG.js +0 -353
  384. solace_agent_mesh/common/a2a/a2a_llm.txt +0 -175
  385. solace_agent_mesh/common/a2a/a2a_llm_detail.txt +0 -193
  386. solace_agent_mesh/common/a2a_spec/a2a_spec_llm.txt +0 -445
  387. solace_agent_mesh/common/a2a_spec/a2a_spec_llm_detail.txt +0 -736
  388. solace_agent_mesh/common/a2a_spec/schemas/schemas_llm.txt +0 -330
  389. solace_agent_mesh/common/common_llm.txt +0 -230
  390. solace_agent_mesh/common/common_llm_detail.txt +0 -2562
  391. solace_agent_mesh/common/middleware/middleware_llm.txt +0 -174
  392. solace_agent_mesh/common/middleware/middleware_llm_detail.txt +0 -185
  393. solace_agent_mesh/common/sac/sac_llm.txt +0 -71
  394. solace_agent_mesh/common/sac/sac_llm_detail.txt +0 -82
  395. solace_agent_mesh/common/sam_events/sam_events_llm.txt +0 -104
  396. solace_agent_mesh/common/sam_events/sam_events_llm_detail.txt +0 -115
  397. solace_agent_mesh/common/services/providers/providers_llm.txt +0 -81
  398. solace_agent_mesh/common/services/services_llm.txt +0 -368
  399. solace_agent_mesh/common/services/services_llm_detail.txt +0 -459
  400. solace_agent_mesh/common/utils/embeds/embeds_llm.txt +0 -220
  401. solace_agent_mesh/common/utils/utils_llm.txt +0 -335
  402. solace_agent_mesh/common/utils/utils_llm_detail.txt +0 -572
  403. solace_agent_mesh/config_portal/frontend/static/client/assets/_index-ByU1X1HD.js +0 -98
  404. solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-61038fc6.js +0 -1
  405. solace_agent_mesh/config_portal/frontend/static/client/assets/root-BWvk5-gF.js +0 -10
  406. solace_agent_mesh/config_portal/frontend/static/client/assets/root-DxRwaWiE.css +0 -1
  407. solace_agent_mesh/core_a2a/core_a2a_llm.txt +0 -90
  408. solace_agent_mesh/core_a2a/core_a2a_llm_detail.txt +0 -101
  409. solace_agent_mesh/gateway/base/base_llm.txt +0 -226
  410. solace_agent_mesh/gateway/base/base_llm_detail.txt +0 -235
  411. solace_agent_mesh/gateway/gateway_llm.txt +0 -369
  412. solace_agent_mesh/gateway/gateway_llm_detail.txt +0 -3885
  413. solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt +0 -345
  414. solace_agent_mesh/gateway/http_sse/alembic/versions/20251023_add_fulltext_search_indexes.py +0 -92
  415. solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt +0 -161
  416. solace_agent_mesh/gateway/http_sse/components/components_llm.txt +0 -105
  417. solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +0 -299
  418. solace_agent_mesh/gateway/http_sse/http_sse_llm_detail.txt +0 -3278
  419. solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt +0 -221
  420. solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt +0 -257
  421. solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt +0 -308
  422. solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt +0 -450
  423. solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt +0 -133
  424. solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt +0 -123
  425. solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +0 -312
  426. solace_agent_mesh/gateway/http_sse/services/services_llm.txt +0 -303
  427. solace_agent_mesh/gateway/http_sse/shared/__init__.py +0 -146
  428. solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt +0 -319
  429. solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt +0 -47
  430. solace_agent_mesh/llm.txt +0 -228
  431. solace_agent_mesh/llm_detail.txt +0 -2835
  432. solace_agent_mesh/solace_agent_mesh_llm.txt +0 -362
  433. solace_agent_mesh/solace_agent_mesh_llm_detail.txt +0 -8599
  434. solace_agent_mesh/templates/logging_config_template.ini +0 -45
  435. solace_agent_mesh/templates/templates_llm.txt +0 -147
  436. /solace_agent_mesh/assets/docs/assets/js/{main.f213fe0c.js.LICENSE.txt → main.d634009f.js.LICENSE.txt} +0 -0
  437. /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/auth_utils.py +0 -0
  438. /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/pagination.py +0 -0
  439. /solace_agent_mesh/{gateway/http_sse/shared → shared/api}/response_utils.py +0 -0
  440. /solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/error_dto.py +0 -0
  441. /solace_agent_mesh/{gateway/http_sse/shared → shared/exceptions}/exceptions.py +0 -0
  442. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/enums.py +0 -0
  443. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/timestamp_utils.py +0 -0
  444. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/types.py +0 -0
  445. /solace_agent_mesh/{gateway/http_sse/shared → shared/utils}/utils.py +0 -0
  446. {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/entry_points.txt +0 -0
  447. {solace_agent_mesh-1.7.1.dist-info → solace_agent_mesh-1.13.2.dist-info}/licenses/LICENSE +0 -0
@@ -1,3278 +0,0 @@
1
- # LLM Summary Detail File
2
-
3
- This file is a concatenation of all individual *llm.txt files found in the 'http_sse' directory tree. Each section below corresponds to a specific directory's summary file.
4
-
5
- ================================================================================
6
-
7
- ## Section 1: solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt
8
-
9
- **Source file:** `solace_agent_mesh/gateway/http_sse/alembic/alembic_llm.txt`
10
-
11
- # DEVELOPER GUIDE: alembic
12
-
13
- ## Quick Summary
14
- This directory contains Alembic database migration configuration and version files for the HTTP SSE gateway. It provides database schema management capabilities, including initial table creation, performance optimization through indexing, timestamp format standardization, and task management features with token usage tracking. The directory consists of the main Alembic environment configuration (`env.py`) and a versions subdirectory containing sequential migration files that handle schema evolution over time.
15
-
16
- ## Files and Subdirectories Overview
17
- - **Direct files:**
18
- - `env.py` - Alembic environment configuration for running migrations in offline/online modes
19
-
20
- - **Subdirectories:**
21
- - `versions/` - Contains sequential database migration files for schema evolution and task management
22
-
23
- ## Developer API Reference
24
-
25
- ### Direct Files
26
-
27
- #### env.py
28
- **Purpose:** Alembic environment configuration that handles migration execution in both offline and online modes with proper model registration
29
- **Import:** This is an Alembic configuration file - not directly imported by application code
30
-
31
- **Functions:**
32
- - `run_migrations_offline() -> None` - Executes migrations without database connection (generates SQL scripts)
33
- - `run_migrations_online() -> None` - Executes migrations with live database connection and proper URL handling
34
-
35
- **Constants/Variables:**
36
- - `config` - Alembic Config object providing access to .ini file values
37
- - `target_metadata` - SQLAlchemy metadata from repository Base class for autogenerate support
38
-
39
- ### Subdirectory APIs
40
-
41
- #### versions/
42
- **Purpose:** Contains sequential Alembic migration files that define database schema changes including core tables, indexes, timestamp modernization, task management, and token usage tracking
43
- **Key Exports:** Migration functions for complete schema evolution (upgrade/downgrade operations)
44
- **Import Examples:**
45
- ```python
46
- # These are migration files executed by Alembic CLI, not directly imported
47
- # Access via Alembic commands:
48
- # alembic upgrade head
49
- # alembic downgrade base
50
- ```
51
-
52
- **Available Migrations:**
53
- - `d5b3f8f2e9a0` - Initial database schema (sessions and chat_messages tables)
54
- - `b1c2d3e4f5g6` - Performance indexes for query optimization
55
- - `f6e7d8c9b0a1` - Timestamp conversion to epoch milliseconds
56
- - `079e06e9b448` - Task management tables (tasks, task_events, feedback)
57
- - `20250930_token_usage` - Token usage tracking columns for AI model consumption monitoring
58
-
59
- ## Complete Usage Guide
60
-
61
- ### 1. Setting Up Alembic Environment
62
-
63
- ```python
64
- # The env.py automatically imports all repository models for metadata
65
- from solace_agent_mesh.gateway.http_sse.repository.models.base import Base
66
- from solace_agent_mesh.gateway.http_sse.repository.models.session_model import SessionModel
67
- from solace_agent_mesh.gateway.http_sse.repository.models.message_model import MessageModel
68
- from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel
69
- from solace_agent_mesh.gateway.http_sse.repository.models.task_event_model import TaskEventModel
70
- from solace_agent_mesh.gateway.http_sse.repository.models.feedback_model import FeedbackModel
71
-
72
- target_metadata = Base.metadata
73
- ```
74
-
75
- ### 2. Running Migrations
76
-
77
- ```bash
78
- # Check current migration status
79
- alembic current
80
-
81
- # Run all pending migrations to latest
82
- alembic upgrade head
83
-
84
- # Run specific migration
85
- alembic upgrade d5b3f8f2e9a0
86
-
87
- # Rollback to previous migration
88
- alembic downgrade -1
89
-
90
- # Rollback to specific migration
91
- alembic downgrade b1c2d3e4f5g6
92
-
93
- # Rollback all migrations
94
- alembic downgrade base
95
-
96
- # View migration history
97
- alembic history
98
- ```
99
-
100
- ### 3. Complete Migration Sequence and Schema Evolution
101
-
102
- ```bash
103
- # Step 1: Create initial database schema
104
- alembic upgrade d5b3f8f2e9a0
105
- # Creates: sessions table, chat_messages table with relationships
106
-
107
- # Step 2: Add performance indexes
108
- alembic upgrade b1c2d3e4f5g6
109
- # Adds: indexes on user_id, timestamps, composite fields
110
-
111
- # Step 3: Modernize timestamp format
112
- alembic upgrade f6e7d8c9b0a1
113
- # Converts: datetime columns to epoch milliseconds
114
- # Renames: columns for consistency (created_at → created_time)
115
-
116
- # Step 4: Add task management features
117
- alembic upgrade 079e06e9b448
118
- # Creates: tasks, task_events, feedback tables with proper relationships
119
-
120
- # Step 5: Add token usage tracking
121
- alembic upgrade 20250930_token_usage
122
- # Adds: token usage columns for AI model consumption monitoring
123
- ```
124
-
125
- ### 4. Working with Different Database Engines
126
-
127
- ```python
128
- # The env.py handles multiple database types automatically
129
- # Configure database URL in alembic.ini or environment:
130
-
131
- # PostgreSQL
132
- # sqlalchemy.url = postgresql://user:pass@localhost/dbname
133
-
134
- # SQLite
135
- # sqlalchemy.url = sqlite:///./database.db
136
-
137
- # MySQL
138
- # sqlalchemy.url = mysql://user:pass@localhost/dbname
139
- ```
140
-
141
- ### 5. Integration with Repository Layer
142
-
143
- ```python
144
- # The migrations work with the repository models
145
- from solace_agent_mesh.gateway.http_sse.repository.models.base import Base
146
- from solace_agent_mesh.gateway.http_sse.repository.models.session_model import SessionModel
147
- from solace_agent_mesh.gateway.http_sse.repository.models.message_model import MessageModel
148
- from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel
149
- from solace_agent_mesh.gateway.http_sse.repository.models.task_event_model import TaskEventModel
150
- from solace_agent_mesh.gateway.http_sse.repository.models.feedback_model import FeedbackModel
151
-
152
- # After running all migrations, your models will have the updated schema:
153
- # - All timestamp fields use epoch milliseconds
154
- # - Proper indexes for performance
155
- # - Standardized column names
156
- # - Complete task management functionality
157
- # - Token usage tracking for AI model consumption
158
- ```
159
-
160
- ### 6. Offline Migration Generation
161
-
162
- ```bash
163
- # Generate SQL scripts without executing (useful for production deployments)
164
- # This uses run_migrations_offline() function from env.py
165
-
166
- # Generate SQL for specific migration
167
- alembic upgrade d5b3f8f2e9a0 --sql
168
-
169
- # Generate SQL for all pending migrations
170
- alembic upgrade head --sql
171
-
172
- # Generate SQL for token usage migration
173
- alembic upgrade 20250930_token_usage --sql
174
- ```
175
-
176
- ### 7. Common Development Patterns
177
-
178
- ```bash
179
- # Development workflow:
180
- # 1. Make model changes in repository
181
- # 2. Generate new migration
182
- alembic revision --autogenerate -m "description of changes"
183
-
184
- # 3. Review generated migration file
185
- # 4. Test migration
186
- alembic upgrade head
187
-
188
- # 5. Test rollback
189
- alembic downgrade -1
190
-
191
- # Production deployment:
192
- # 1. Generate SQL scripts
193
- alembic upgrade head --sql > migration.sql
194
-
195
- # 2. Review and execute SQL manually in production
196
- ```
197
-
198
- ### 8. Database Schema After All Migrations
199
-
200
- ```sql
201
- -- Final schema structure after all migrations:
202
-
203
- -- Core tables:
204
- -- sessions table:
205
- -- id (String, Primary Key)
206
- -- name (String)
207
- -- user_id (String, Indexed)
208
- -- agent_id (String)
209
- -- created_time (BigInteger, epoch ms)
210
- -- updated_time (BigInteger, epoch ms)
211
-
212
- -- chat_messages table:
213
- -- id (String, Primary Key)
214
- -- session_id (String, Foreign Key to sessions.id)
215
- -- message (Text)
216
- -- sender_type (String)
217
- -- sender_name (String)
218
- -- created_time (BigInteger, epoch ms, Indexed)
219
-
220
- -- Task management tables:
221
- -- tasks table:
222
- -- id (String, Primary Key)
223
- -- user_id (String, Indexed)
224
- -- start_time (BigInteger, epoch ms)
225
- -- end_time (BigInteger, epoch ms)
226
- -- status (String)
227
- -- initial_request_text (Text)
228
- -- total_input_tokens (Integer)
229
- -- total_output_tokens (Integer)
230
- -- total_cached_input_tokens (Integer)
231
- -- token_usage_details (Text, JSON)
232
-
233
- -- task_events table:
234
- -- id (String, Primary Key)
235
- -- task_id (String, Foreign Key to tasks.id)
236
- -- user_id (String)
237
- -- created_time (BigInteger, epoch ms)
238
- -- topic (String)
239
- -- direction (String)
240
- -- payload (Text)
241
-
242
- -- feedback table:
243
- -- id (String, Primary Key)
244
- -- session_id (String, Foreign Key to sessions.id)
245
- -- task_id (String, Foreign Key to tasks.id)
246
- -- user_id (String)
247
- -- rating (Integer)
248
- -- comment (Text)
249
- -- created_time (BigInteger, epoch ms)
250
-
251
- -- Performance indexes:
252
- -- idx_sessions_user_id
253
- -- idx_sessions_created_time
254
- -- idx_sessions_updated_time
255
- -- idx_chat_messages_session_id
256
- -- idx_chat_messages_created_time
257
- -- idx_chat_messages_session_created (composite)
258
- -- idx_tasks_user_id
259
- -- idx_task_events_task_id
260
- -- idx_task_events_created_time
261
- -- idx_feedback_session_id
262
- -- idx_feedback_task_id
263
- ```
264
-
265
- ### 9. Cross-Platform Timestamp Handling
266
-
267
- ```python
268
- # The f6e7d8c9b0a1 migration handles database-specific timestamp conversion:
269
-
270
- # SQLite: Uses table recreation approach
271
- # - Creates new tables with epoch millisecond columns
272
- # - Migrates data with timestamp conversion
273
- # - Drops old tables and renames new ones
274
-
275
- # PostgreSQL/MySQL: Uses ALTER COLUMN approach
276
- # - Directly modifies column types
277
- # - Converts existing data in place
278
- # - More efficient for large datasets
279
- ```
280
-
281
- ### 10. Token Usage Tracking
282
-
283
- ```python
284
- # The 20250930_token_usage migration adds AI model consumption tracking:
285
-
286
- # Token usage columns added to tasks table:
287
- # - total_input_tokens: Total input tokens consumed
288
- # - total_output_tokens: Total output tokens generated
289
- # - total_cached_input_tokens: Cached input tokens used
290
- # - token_usage_details: JSON field for detailed token usage breakdown
291
-
292
- # Usage example after migration:
293
- from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel
294
-
295
- # Query tasks with token usage
296
- task = session.query(TaskModel).filter_by(id="task_id").first()
297
- print(f"Input tokens: {task.total_input_tokens}")
298
- print(f"Output tokens: {task.total_output_tokens}")
299
- print(f"Cached tokens: {task.total_cached_input_tokens}")
300
- print(f"Details: {task.token_usage_details}")
301
- ```
302
-
303
- This Alembic configuration provides a comprehensive database migration system that handles schema evolution, performance optimization, cross-database compatibility, complete task management functionality, and AI model token usage tracking for the HTTP SSE gateway component.
304
-
305
- ================================================================================
306
-
307
- ## Section 2: solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt
308
-
309
- **Source file:** `solace_agent_mesh/gateway/http_sse/alembic/versions/versions_llm.txt`
310
-
311
- # DEVELOPER GUIDE: versions
312
-
313
- ## Quick Summary
314
- This directory contains Alembic database migration files for the HTTP SSE gateway. These migrations handle the evolution of the database schema, including initial table creation, performance optimization through indexing, timestamp format standardization, and task management features with token usage tracking.
315
-
316
- ## Files Overview
317
- - `20250910_d5b3f8f2e9a0_create_initial_database.py` - Creates the initial database schema with sessions and chat_messages tables
318
- - `20250911_b1c2d3e4f5g6_add_database_indexes.py` - Adds performance indexes for common query patterns
319
- - `20250916_f6e7d8c9b0a1_convert_timestamps_to_epoch_and_align_columns.py` - Converts datetime columns to epoch milliseconds and standardizes column names
320
- - `20250928_079e06e9b448_add_tasks_task_events_and_feedback_.py` - Adds task management tables (tasks, task_events, feedback)
321
- - `20250930_add_token_usage_to_tasks.py` - Adds token usage tracking columns to tasks table
322
- - `versions_llm.txt` - LLM-generated documentation for the versions directory
323
-
324
- ## Developer API Reference
325
-
326
- ### 20250910_d5b3f8f2e9a0_create_initial_database.py
327
- **Purpose:** Initial database migration that creates the core tables for session and message management
328
- **Import:** This is an Alembic migration file - not directly imported
329
-
330
- **Functions:**
331
- - `upgrade() -> None` - Creates sessions and chat_messages tables with proper relationships and foreign key constraints
332
- - `downgrade() -> None` - Drops all created tables (chat_messages first, then sessions)
333
-
334
- **Constants/Variables:**
335
- - `revision: str` - Migration identifier "d5b3f8f2e9a0"
336
- - `down_revision: Union[str, None]` - Previous migration (None for initial migration)
337
- - `branch_labels: Union[str, Sequence[str], None]` - Branch labels (None)
338
- - `depends_on: Union[str, Sequence[str], None]` - Dependencies (None)
339
-
340
- **Usage Examples:**
341
- ```bash
342
- # Run this migration
343
- alembic upgrade d5b3f8f2e9a0
344
-
345
- # Rollback this migration
346
- alembic downgrade base
347
- ```
348
-
349
- ### 20250911_b1c2d3e4f5g6_add_database_indexes.py
350
- **Purpose:** Performance optimization migration that adds indexes for efficient querying
351
- **Import:** This is an Alembic migration file - not directly imported
352
-
353
- **Functions:**
354
- - `upgrade() -> None` - Creates indexes on user_id, timestamps, agent_id, and composite fields for optimal query performance
355
- - `downgrade() -> None` - Removes all created indexes in reverse order
356
-
357
- **Constants/Variables:**
358
- - `revision: str` - Migration identifier "b1c2d3e4f5g6"
359
- - `down_revision: Union[str, None]` - Previous migration "d5b3f8f2e9a0"
360
-
361
- **Usage Examples:**
362
- ```bash
363
- # Run this migration
364
- alembic upgrade b1c2d3e4f5g6
365
-
366
- # Rollback this migration
367
- alembic downgrade d5b3f8f2e9a0
368
- ```
369
-
370
- ### 20250916_f6e7d8c9b0a1_convert_timestamps_to_epoch_and_align_columns.py
371
- **Purpose:** Schema modernization migration that converts datetime columns to epoch milliseconds for cross-platform compatibility
372
- **Import:** This is an Alembic migration file - not directly imported
373
-
374
- **Functions:**
375
- - `upgrade() -> None` - Converts datetime columns to epoch milliseconds and renames columns (created_at → created_time, updated_at → updated_time)
376
- - `downgrade() -> None` - Reverts back to datetime columns with original names
377
- - `_upgrade_sqlite(current_time_ms: int) -> None` - SQLite-specific upgrade logic using table recreation
378
- - `_upgrade_standard_sql(current_time_ms: int) -> None` - PostgreSQL/MySQL upgrade logic using ALTER COLUMN
379
- - `_downgrade_sqlite() -> None` - SQLite-specific downgrade logic
380
- - `_downgrade_standard_sql() -> None` - PostgreSQL/MySQL downgrade logic
381
- - `_create_updated_indexes() -> None` - Creates indexes on new timestamp columns
382
- - `_create_indexes_safe(index_name: str, table_name: str, columns: list) -> None` - Safely creates indexes (ignores if exists)
383
- - `_drop_index_safe(index_name: str, table_name: str) -> None` - Safely drops indexes (ignores if not exists)
384
-
385
- **Constants/Variables:**
386
- - `revision: str` - Migration identifier "f6e7d8c9b0a1"
387
- - `down_revision: str | None` - Previous migration "b1c2d3e4f5g6"
388
-
389
- **Usage Examples:**
390
- ```bash
391
- # Run this migration
392
- alembic upgrade f6e7d8c9b0a1
393
-
394
- # Rollback this migration
395
- alembic downgrade b1c2d3e4f5g6
396
- ```
397
-
398
- ### 20250928_079e06e9b448_add_tasks_task_events_and_feedback_.py
399
- **Purpose:** Adds task management functionality with tables for tracking tasks, events, and user feedback
400
- **Import:** This is an Alembic migration file - not directly imported
401
-
402
- **Functions:**
403
- - `upgrade() -> None` - Creates tasks, task_events, and feedback tables with appropriate indexes and foreign key relationships
404
- - `downgrade() -> None` - Drops all task-related tables and recreates original session/message indexes
405
-
406
- **Constants/Variables:**
407
- - `revision: str` - Migration identifier "079e06e9b448"
408
- - `down_revision: Union[str, Sequence[str], None]` - Previous migration "f6e7d8c9b0a1"
409
-
410
- **Usage Examples:**
411
- ```bash
412
- # Run this migration
413
- alembic upgrade 079e06e9b448
414
-
415
- # Rollback this migration
416
- alembic downgrade f6e7d8c9b0a1
417
- ```
418
-
419
- ### 20250930_add_token_usage_to_tasks.py
420
- **Purpose:** Adds token usage tracking columns to the tasks table for monitoring AI model consumption
421
- **Import:** This is an Alembic migration file - not directly imported
422
-
423
- **Functions:**
424
- - `upgrade() -> None` - Adds token usage columns (total_input_tokens, total_output_tokens, total_cached_input_tokens, token_usage_details) to tasks table
425
- - `downgrade() -> None` - Removes all token usage columns from tasks table
426
-
427
- **Constants/Variables:**
428
- - `revision: str` - Migration identifier "20250930_token_usage"
429
- - `down_revision: Union[str, None]` - Previous migration "079e06e9b448"
430
-
431
- **Usage Examples:**
432
- ```bash
433
- # Run this migration
434
- alembic upgrade 20250930_token_usage
435
-
436
- # Rollback this migration
437
- alembic downgrade 079e06e9b448
438
-
439
- # Run all migrations to latest
440
- alembic upgrade head
441
-
442
- # Check current migration status
443
- alembic current
444
-
445
- # View migration history
446
- alembic history
447
-
448
- # Generate new migration
449
- alembic revision --autogenerate -m "description"
450
- ```
451
-
452
- **Database Schema After All Migrations:**
453
- ```sql
454
- -- Core tables with epoch millisecond timestamps:
455
- -- sessions: id, name, user_id, agent_id, created_time, updated_time
456
- -- chat_messages: id, session_id, message, sender_type, sender_name, created_time
457
-
458
- -- Task management tables:
459
- -- tasks: id, user_id, start_time, end_time, status, initial_request_text,
460
- -- total_input_tokens, total_output_tokens, total_cached_input_tokens, token_usage_details
461
- -- task_events: id, task_id, user_id, created_time, topic, direction, payload
462
- -- feedback: id, session_id, task_id, user_id, rating, comment, created_time
463
- ```
464
-
465
- ================================================================================
466
-
467
- ## Section 3: solace_agent_mesh/gateway/http_sse/components/components_llm.txt
468
-
469
- **Source file:** `solace_agent_mesh/gateway/http_sse/components/components_llm.txt`
470
-
471
- # DEVELOPER GUIDE: components
472
-
473
- ## Quick Summary
474
- This directory contains SAC (Solace AI Connector) components for the HTTP SSE (Server-Sent Events) gateway. These components forward messages from Solace broker inputs to internal Python queues, enabling real-time visualization and task logging in web-based user interfaces.
475
-
476
- ## Files Overview
477
- - `__init__.py` - Makes the `VisualizationForwarderComponent` class directly importable from the components package
478
- - `components_llm.txt` - Developer guide documentation for this directory
479
- - `task_logger_forwarder.py` - SAC component that forwards messages to a task logging queue
480
- - `visualization_forwarder_component.py` - SAC component that forwards messages to a visualization queue
481
-
482
- ## Developer API Reference
483
-
484
- ### __init__.py
485
- **Purpose:** Exposes the public components of this directory for easy importing
486
- **Import:** `from solace_agent_mesh.gateway.http_sse.components import VisualizationForwarderComponent`
487
-
488
- **Exports:**
489
- - `VisualizationForwarderComponent` - The main component class for forwarding messages to a visualization queue
490
-
491
- ### task_logger_forwarder.py
492
- **Purpose:** A SAC component that forwards messages from a BrokerInput to a target queue for task logging
493
- **Import:** `from solace_agent_mesh.gateway.http_sse.components.task_logger_forwarder import TaskLoggerForwarderComponent`
494
-
495
- **Classes:**
496
- - `TaskLoggerForwarderComponent(**kwargs: Any)` - A component that forwards messages to a task logging queue, initialized with configuration parameters including `target_queue_ref`
497
- - `invoke(message: SolaceMessage, data: Dict[str, Any]) -> None` - Core method called by SAC framework for each incoming message; formats data and places it onto the target queue
498
- - `target_queue: queue.Queue` - The queue instance where messages are forwarded
499
-
500
- **Constants/Variables:**
501
- - `info: Dict` - Metadata dictionary required by SAC framework describing component configuration, input schema, and purpose
502
-
503
- **Usage Examples:**
504
- ```python
505
- import queue
506
- from solace_agent_mesh.gateway.http_sse.components.task_logger_forwarder import TaskLoggerForwarderComponent
507
- from solace_ai_connector.common.message import Message as SolaceMessage
508
-
509
- # 1. Create a target queue for task logging
510
- task_logging_queue = queue.Queue()
511
-
512
- # 2. Instantiate the component with target queue reference
513
- task_forwarder = TaskLoggerForwarderComponent(
514
- name="task_logger",
515
- target_queue_ref=task_logging_queue
516
- )
517
-
518
- # 3. The invoke method is called automatically by SAC framework
519
- # when messages arrive from connected BrokerInput component
520
-
521
- # 4. Consume forwarded messages from the queue
522
- if not task_logging_queue.empty():
523
- forwarded_data = task_logging_queue.get()
524
- print(f"Task Topic: {forwarded_data['topic']}")
525
- print(f"Task Payload: {forwarded_data['payload']}")
526
- print(f"User Properties: {forwarded_data['user_properties']}")
527
- ```
528
-
529
- ### visualization_forwarder_component.py
530
- **Purpose:** A SAC component that forwards messages from a BrokerInput to a target queue for visualization
531
- **Import:** `from solace_agent_mesh.gateway.http_sse.components.visualization_forwarder_component import VisualizationForwarderComponent`
532
-
533
- **Classes:**
534
- - `VisualizationForwarderComponent(**kwargs: Any)` - A component that forwards messages to a visualization queue, initialized with configuration parameters including `target_queue_ref`
535
- - `invoke(message: SolaceMessage, data: Dict[str, Any]) -> None` - Core method called by SAC framework for each incoming message; formats data and places it onto the target queue
536
- - `target_queue: queue.Queue` - The queue instance where messages are forwarded
537
-
538
- **Constants/Variables:**
539
- - `info: Dict` - Metadata dictionary required by SAC framework describing component configuration, input schema, and purpose
540
-
541
- **Usage Examples:**
542
- ```python
543
- import queue
544
- from solace_agent_mesh.gateway.http_sse.components import VisualizationForwarderComponent
545
- from solace_ai_connector.common.message import Message as SolaceMessage
546
-
547
- # 1. Create a target queue that will receive the forwarded messages
548
- visualization_queue = queue.Queue()
549
-
550
- # 2. Instantiate the component with target queue reference
551
- forwarder = VisualizationForwarderComponent(
552
- name="my_forwarder",
553
- target_queue_ref=visualization_queue
554
- )
555
-
556
- # 3. The invoke method is called automatically by SAC framework
557
- # when messages arrive from connected BrokerInput component
558
-
559
- # 4. Consume forwarded messages from the queue
560
- if not visualization_queue.empty():
561
- forwarded_data = visualization_queue.get()
562
- print(f"Topic: {forwarded_data['topic']}")
563
- print(f"Payload: {forwarded_data['payload']}")
564
- print(f"User Properties: {forwarded_data['user_properties']}")
565
-
566
- # Expected structure of forwarded_data:
567
- # {
568
- # "topic": "some/broker/topic",
569
- # "payload": {"key": "value"},
570
- # "user_properties": {"prop1": "value1"},
571
- # "_original_broker_message": <SolaceMessage object>
572
- # }
573
- ```
574
-
575
- ================================================================================
576
-
577
- ## Section 4: solace_agent_mesh/gateway/http_sse/http_sse_llm.txt
578
-
579
- **Source file:** `solace_agent_mesh/gateway/http_sse/http_sse_llm.txt`
580
-
581
- # DEVELOPER GUIDE: http_sse
582
-
583
- ## Quick Summary
584
- The `http_sse` directory implements a complete HTTP/SSE (Server-Sent Events) gateway for the A2A (Agent-to-Agent) system. It serves as a bridge between web-based user interfaces and the backend A2A messaging fabric, providing real-time communication capabilities through HTTP REST APIs and Server-Sent Events streaming.
585
-
586
- The architecture centers around the `WebUIBackendComponent`, a custom Solace AI Connector (SAC) component that hosts an embedded FastAPI web server. This component manages shared resources including the `SSEManager` for real-time updates, `SessionManager` for user sessions, and `AgentRegistry` for agent discovery. The system provides comprehensive functionality including session management, task logging, data retention, feedback collection, and A2A message visualization.
587
-
588
- Subdirectories organize functionality by layer: `routers/` defines REST API endpoints, `services/` contains business logic, `repository/` handles data persistence, `components/` provides specialized SAC components, and `shared/` contains common utilities. The `dependencies.py` file uses FastAPI's dependency injection to provide clean separation between the web layer and core messaging components.
589
-
590
- ## Files and Subdirectories Overview
591
- - **Direct files:**
592
- - `__init__.py`: Standard Python package initializer
593
- - `alembic.ini`: Alembic database migration configuration
594
- - `app.py`: Main SAC `WebUIBackendApp` class defining configuration schema and component creation
595
- - `component.py`: Core SAC component hosting FastAPI server and managing shared resources
596
- - `dependencies.py`: FastAPI dependency injectors for accessing shared resources
597
- - `main.py`: FastAPI application instance with middleware, routing, and exception handling
598
- - `session_manager.py`: Web user session management and A2A identity mapping
599
- - `sse_manager.py`: Server-Sent Event connection management for real-time streaming
600
- - `sse_event_buffer.py`: Thread-safe buffer for early SSE events before client connection
601
- - **Subdirectories:**
602
- - `alembic/`: Database migration configuration and version files
603
- - `components/`: Specialized SAC components for message forwarding and visualization
604
- - `repository/`: Data access layer with Repository pattern and SQLAlchemy ORM models
605
- - `routers/`: FastAPI router modules defining REST API endpoints
606
- - `services/`: Business logic layer for domain-specific operations
607
- - `shared/`: Common utilities, constants, enums, and exception handling
608
- - `utils/`: Utility functions for creating .stim file structures from task data
609
-
610
- ## Developer API Reference
611
-
612
- ### Direct Files
613
-
614
- #### app.py
615
- **Purpose:** Defines the main SAC application class with configuration schema for the HTTP/SSE gateway
616
- **Import:** `from solace_agent_mesh.gateway.http_sse.app import WebUIBackendApp`
617
-
618
- **Classes/Functions/Constants:**
619
- - **`WebUIBackendApp(BaseGatewayApp)`**: Main application class extending BaseGatewayApp with WebUI-specific configuration
620
- - `get_component() -> WebUIBackendComponent | None`: Retrieves the running component instance
621
- - `_get_gateway_component_class() -> type[BaseGatewayComponent]`: Returns WebUIBackendComponent class
622
- - **`SPECIFIC_APP_SCHEMA_PARAMS: List[Dict[str, Any]]`**: Configuration parameters including session_secret_key, FastAPI settings, frontend configuration, database settings, and feature flags
623
-
624
- #### component.py
625
- **Purpose:** Core SAC component hosting FastAPI server and managing all shared resources and A2A logic
626
- **Import:** `from solace_agent_mesh.gateway.http_sse.component import WebUIBackendComponent`
627
-
628
- **Classes/Functions/Constants:**
629
- - **`WebUIBackendComponent(BaseGatewayComponent)`**: Main component class implementing the gateway functionality
630
- - **Public Accessor Methods:**
631
- - `get_sse_manager() -> SSEManager`: Returns SSE manager for real-time updates
632
- - `get_session_manager() -> SessionManager`: Returns session manager
633
- - `get_agent_registry() -> AgentRegistry`: Returns agent registry
634
- - `get_core_a2a_service() -> CoreA2AService`: Returns core A2A service
635
- - `get_shared_artifact_service() -> BaseArtifactService | None`: Returns artifact service
636
- - `get_namespace() -> str`: Returns A2A namespace
637
- - `get_gateway_id() -> str`: Returns unique gateway identifier
638
- - **Core Methods:**
639
- - `publish_a2a(topic: str, payload: dict, user_properties: dict | None = None)`: Publishes A2A messages
640
- - **GDK Implementation Methods:**
641
- - `_start_listener()`: Starts FastAPI server
642
- - `_stop_listener()`: Stops FastAPI server
643
- - `_translate_external_input(...)`: Converts HTTP requests to A2A messages
644
- - `_send_update_to_external(...)`: Sends intermediate updates via SSE
645
- - `_send_final_response_to_external(...)`: Sends final responses via SSE
646
- - `_send_error_to_external(...)`: Sends error notifications via SSE
647
-
648
- #### dependencies.py
649
- **Purpose:** FastAPI dependency injectors providing access to shared resources
650
- **Import:** `from solace_agent_mesh.gateway.http_sse.dependencies import get_sac_component, get_agent_registry, get_sse_manager, get_user_id`
651
-
652
- **Functions:**
653
- - `get_sac_component() -> WebUIBackendComponent`: Returns main component instance
654
- - `get_agent_registry() -> AgentRegistry`: Returns agent registry
655
- - `get_sse_manager() -> SSEManager`: Returns SSE manager
656
- - `get_session_manager() -> SessionManager`: Returns session manager
657
- - `get_user_id(request: Request) -> str`: Returns current user identity
658
- - `get_publish_a2a_func() -> PublishFunc`: Returns A2A publishing function
659
- - `get_core_a2a_service() -> CoreA2AService`: Returns core A2A service
660
- - `get_shared_artifact_service() -> BaseArtifactService | None`: Returns artifact service
661
- - `get_db() -> Generator[Session, None, None]`: Returns database session
662
- - `ValidatedUserConfig(required_scopes: list[str])`: Dependency class for scope validation
663
-
664
- #### main.py
665
- **Purpose:** FastAPI application instance with middleware, routing, and exception handling
666
- **Import:** `from solace_agent_mesh.gateway.http_sse.main import app, setup_dependencies`
667
-
668
- **Classes/Functions/Constants:**
669
- - **`app: FastAPI`**: Main FastAPI application instance
670
- - **`setup_dependencies(component: WebUIBackendComponent, database_url: str = None)`**: Configures middleware, routers, and dependency injection
671
- - **Exception Handlers:**
672
- - `http_exception_handler()`: Handles HTTP exceptions with format detection
673
- - `validation_exception_handler()`: Handles Pydantic validation errors
674
- - `generic_exception_handler()`: Handles unexpected exceptions
675
-
676
- #### session_manager.py
677
- **Purpose:** Manages web user sessions and mapping to A2A Client IDs
678
- **Import:** `from solace_agent_mesh.gateway.http_sse.session_manager import SessionManager`
679
-
680
- **Classes/Functions/Constants:**
681
- - **`SessionManager(secret_key: str, app_config: Dict[str, Any])`**: Session management class
682
- - `get_a2a_client_id(request: Request) -> str | None`: Returns A2A client ID
683
- - `start_new_a2a_session(request: Request) -> str`: Creates new A2A session
684
- - `ensure_a2a_session(request: Request) -> str`: Ensures session exists
685
- - `store_auth_tokens(request: Request, access_token: str, refresh_token: str | None)`: Stores auth tokens
686
- - `get_access_token(request: Request) -> str | None`: Retrieves access token
687
- - `dep_get_client_id() -> Callable`: Returns FastAPI dependency callable
688
-
689
- #### sse_manager.py
690
- **Purpose:** Manages Server-Sent Event connections for streaming task updates
691
- **Import:** `from solace_agent_mesh.gateway.http_sse.sse_manager import SSEManager`
692
-
693
- **Classes/Functions/Constants:**
694
- - **`SSEManager(max_queue_size: int, event_buffer: SSEEventBuffer)`**: SSE connection manager
695
- - `create_sse_connection(task_id: str) -> asyncio.Queue`: Creates SSE connection queue
696
- - `send_event(task_id: str, event_data: Dict[str, Any], event_type: str)`: Sends event to connections
697
- - `close_all_for_task(task_id: str)`: Closes connections for specific task
698
- - `close_all()`: Closes all active connections
699
-
700
- #### sse_event_buffer.py
701
- **Purpose:** Thread-safe buffer for holding early SSE events before client connection
702
- **Import:** `from solace_agent_mesh.gateway.http_sse.sse_event_buffer import SSEEventBuffer`
703
-
704
- **Classes/Functions/Constants:**
705
- - **`SSEEventBuffer(max_queue_size: int, max_age_seconds: int)`**: Event buffering system
706
- - `buffer_event(task_id: str, event: Dict[str, Any])`: Buffers event for task
707
- - `get_and_remove_buffer(task_id: str) -> Optional[List[Dict[str, Any]]]`: Retrieves and removes buffer
708
- - `cleanup_stale_buffers()`: Removes old buffers
709
-
710
- ### Subdirectory APIs
711
-
712
- #### alembic/
713
- **Purpose:** Database migration configuration and version files for schema management
714
- **Key Exports:** Migration functions for schema evolution (upgrade/downgrade operations)
715
- **Import Examples:**
716
- ```python
717
- # These are migration files executed by Alembic CLI, not directly imported
718
- # Access via Alembic commands:
719
- # alembic upgrade head
720
- # alembic downgrade base
721
- ```
722
-
723
- #### components/
724
- **Purpose:** Specialized SAC components for message forwarding and visualization
725
- **Key Exports:** `VisualizationForwarderComponent`, `TaskLoggerForwarderComponent`
726
- **Import Examples:**
727
- ```python
728
- from solace_agent_mesh.gateway.http_sse.components import VisualizationForwarderComponent
729
- from solace_agent_mesh.gateway.http_sse.components.task_logger_forwarder import TaskLoggerForwarderComponent
730
- ```
731
-
732
- #### repository/
733
- **Purpose:** Data access layer implementing Repository pattern with SQLAlchemy ORM models
734
- **Key Exports:** Repository interfaces, implementations, domain entities, and SQLAlchemy models
735
- **Import Examples:**
736
- ```python
737
- from solace_agent_mesh.gateway.http_sse.repository import (
738
- ISessionRepository, IMessageRepository, SessionRepository, MessageRepository,
739
- Session, Message, SessionHistory, Base, SessionModel, MessageModel
740
- )
741
- ```
742
-
743
- #### routers/
744
- **Purpose:** FastAPI router modules defining REST API endpoints
745
- **Key Exports:** Router instances for agents, tasks, SSE, artifacts, auth, config, sessions, people, users, visualization
746
- **Import Examples:**
747
- ```python
748
- from solace_agent_mesh.gateway.http_sse.routers import agents, tasks, sse, artifacts
749
- from solace_agent_mesh.gateway.http_sse.routers.tasks import CancelTaskApiPayload
750
- ```
751
-
752
- #### services/
753
- **Purpose:** Business logic layer for domain-specific operations
754
- **Key Exports:** `AgentCardService`, `TaskService`, `PeopleService`, `SessionService`, `FeedbackService`, `TaskLoggerService`
755
- **Import Examples:**
756
- ```python
757
- from solace_agent_mesh.gateway.http_sse.services.agent_card_service import AgentCardService
758
- from solace_agent_mesh.gateway.http_sse.services.task_service import TaskService
759
- from solace_agent_mesh.gateway.http_sse.services.people_service import PeopleService
760
- ```
761
-
762
- #### shared/
763
- **Purpose:** Common utilities, constants, enums, and exception handling
764
- **Key Exports:** Authentication utilities, timestamp functions, enums, exception handlers, and type definitions
765
- **Import Examples:**
766
- ```python
767
- from solace_agent_mesh.gateway.http_sse.shared import get_current_user, now_epoch_ms
768
- from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType, TaskStatus
769
- from solace_agent_mesh.gateway.http_sse.shared.types import UserId, SessionId, PaginationInfo
770
- ```
771
-
772
- #### utils/
773
- **Purpose:** Utility functions for creating .stim file structures from task data
774
- **Key Exports:** `create_stim_from_task_data`
775
- **Import Examples:**
776
- ```python
777
- from solace_agent_mesh.gateway.http_sse.utils.stim_utils import create_stim_from_task_data
778
- ```
779
-
780
- ## Complete Usage Guide
781
-
782
- ### 1. Setting Up the Gateway Application
783
-
784
- ```python
785
- from solace_agent_mesh.gateway.http_sse.app import WebUIBackendApp
786
-
787
- # Create the gateway app with configuration
788
- app_config = {
789
- "name": "my-webui-gateway",
790
- "session_secret_key": "your-secret-key-here",
791
- "fastapi_host": "0.0.0.0",
792
- "fastapi_port": 8000,
793
- "namespace": "/my-namespace",
794
- "gateway_id": "webui-gateway-01",
795
- "cors_allowed_origins": ["http://localhost:3000"],
796
- "frontend_welcome_message": "Welcome to my A2A system!",
797
- "frontend_bot_name": "My Assistant",
798
- # Database configuration for persistence
799
- "session_service": {
800
- "type": "sql",
801
- "database_url": "sqlite:///./sessions.db"
802
- },
803
- # Task logging configuration
804
- "task_logging": {
805
- "enabled": True,
806
- "log_status_updates": True,
807
- "log_artifact_events": True
808
- },
809
- # Data retention configuration
810
- "data_retention": {
811
- "enabled": True,
812
- "task_retention_days": 90,
813
- "cleanup_interval_hours": 24
814
- }
815
- }
816
-
817
- # Initialize and run the app
818
- webui_app = WebUIBackendApp(app_info=app_config)
819
- webui_app.run()
820
- ```
821
-
822
- ### 2. Using Dependencies in Custom Routers
823
-
824
- ```python
825
- from fastapi import APIRouter, Depends
826
- from solace_agent_mesh.gateway.http_sse.dependencies import (
827
- get_agent_registry,
828
- get_user_id,
829
- get_publish_a2a_func,
830
- get_core_a2a_service,
831
- get_sse_manager,
832
- ValidatedUserConfig
833
- )
834
- from solace_agent_mesh.common.agent_registry import AgentRegistry
835
-
836
- router = APIRouter()
837
-
838
- @router.get("/my-custom-endpoint")
839
- async def my_custom_endpoint(
840
- user_id: str = Depends(get_user_id),
841
- agent_registry: AgentRegistry = Depends(get_agent_registry),
842
- publish_func = Depends(get_publish_a2a_func),
843
- user_config: dict = Depends(ValidatedUserConfig(["custom:endpoint:access"]))
844
- ):
845
- # Access discovered agents
846
- agents = agent_registry.get_all_agents()
847
-
848
- # Publish a message to the A2A fabric
849
- publish_func(
850
- topic=f"/my-namespace/a2a/v1/agent/request/some-agent",
851
- payload={"method": "custom/request", "params": {"user": user_id}},
852
- user_properties={"clientId": user_id}
853
- )
854
-
855
- return {"agents": len(agents), "user": user_id}
856
- ```
857
-
858
- ### 3. Working with Sessions and Messages
859
-
860
- ```python
861
- from fastapi import Depends
862
- from sqlalchemy.orm import Session
863
- from solace_agent_mesh.gateway.http_sse.dependencies import (
864
- get_db, get_session_business_service_optional
865
- )
866
- from solace_agent_mesh.gateway.http_sse.services.session_service import SessionService
867
- from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType
868
-
869
- @router.post("/sessions/{session_id}/messages")
870
- async def add_message_to_session(
871
- session_id: str,
872
- message_text: str,
873
- user_id: str = Depends(get_user_id),
874
- db: Session = Depends(get_db),
875
- session_service: SessionService = Depends(get_session_business_service_optional)
876
- ):
877
- if session_
878
-
879
- ================================================================================
880
-
881
- ## Section 5: solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt
882
-
883
- **Source file:** `solace_agent_mesh/gateway/http_sse/repository/entities/entities_llm.txt`
884
-
885
- # DEVELOPER GUIDE: entities
886
-
887
- ## Quick Summary
888
- The entities directory contains domain entities for the repository layer, providing core business objects for managing chat sessions, messages, tasks, feedback, and events with built-in validation and business logic.
889
-
890
- ## Files Overview
891
- - `__init__.py` - Exports the main domain entities (Feedback, Message, Session, SessionHistory, Task, TaskEvent)
892
- - `feedback.py` - Feedback entity for user ratings and comments on tasks
893
- - `message.py` - Message entity with content validation and sender type checking
894
- - `session.py` - Session entity with name management and access control
895
- - `session_history.py` - Composite entity combining sessions with their message history
896
- - `task.py` - Task entity for tracking user tasks and their status with token usage
897
- - `task_event.py` - Task event entity for tracking events related to tasks
898
-
899
- ## Developer API Reference
900
-
901
- ### __init__.py
902
- **Purpose:** Provides centralized imports for all domain entities
903
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import Feedback, Message, Session, SessionHistory, Task, TaskEvent`
904
-
905
- ### feedback.py
906
- **Purpose:** Defines the Feedback domain entity for user ratings and comments
907
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import Feedback`
908
-
909
- **Classes:**
910
- - `Feedback(id: str, session_id: str, task_id: str, user_id: str, rating: str, comment: str | None = None, created_time: int)` - Feedback domain entity
911
- - `id: str` - Unique feedback identifier
912
- - `session_id: str` - Associated session identifier
913
- - `task_id: str` - Associated task identifier
914
- - `user_id: str` - User who provided feedback
915
- - `rating: str` - User rating
916
- - `comment: str | None` - Optional feedback comment
917
- - `created_time: int` - Feedback creation timestamp
918
-
919
- **Usage Examples:**
920
- ```python
921
- from solace_agent_mesh.gateway.http_sse.repository.entities import Feedback
922
-
923
- # Create feedback
924
- feedback = Feedback(
925
- id="feedback_123",
926
- session_id="session_456",
927
- task_id="task_789",
928
- user_id="user_123",
929
- rating="5",
930
- comment="Great service!",
931
- created_time=1640995200000
932
- )
933
- ```
934
-
935
- ### message.py
936
- **Purpose:** Defines the Message domain entity with business logic for chat messages
937
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import Message`
938
-
939
- **Classes:**
940
- - `Message(id: MessageId, session_id: SessionId, message: str, sender_type: SenderType, sender_name: str, message_type: MessageType = MessageType.TEXT, created_time: int)` - Message domain entity with business logic
941
- - `validate_message_content() -> None` - Validates message content is not empty and under 10MB limit
942
- - `is_from_user() -> bool` - Checks if message is from a user
943
- - `is_from_agent() -> bool` - Checks if message is from an agent
944
- - `is_system_message() -> bool` - Checks if message is a system message
945
- - `id: MessageId` - Unique message identifier
946
- - `session_id: SessionId` - Associated session identifier
947
- - `message: str` - Message content
948
- - `sender_type: SenderType` - Type of sender (USER, AGENT, SYSTEM)
949
- - `sender_name: str` - Name of the message sender
950
- - `message_type: MessageType` - Type of message content
951
- - `created_time: int` - Message creation timestamp
952
-
953
- **Usage Examples:**
954
- ```python
955
- from solace_agent_mesh.gateway.http_sse.repository.entities import Message
956
- from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType, MessageType
957
-
958
- # Create a user message
959
- message = Message(
960
- id="msg_123",
961
- session_id="session_456",
962
- message="Hello, how can I help?",
963
- sender_type=SenderType.USER,
964
- sender_name="John Doe",
965
- message_type=MessageType.TEXT,
966
- created_time=1640995200000
967
- )
968
-
969
- # Validate message content
970
- message.validate_message_content()
971
-
972
- # Check sender type
973
- if message.is_from_user():
974
- print("Message from user")
975
- ```
976
-
977
- ### session.py
978
- **Purpose:** Defines the Session domain entity with business logic for chat sessions
979
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import Session`
980
-
981
- **Classes:**
982
- - `Session(id: SessionId, user_id: UserId, name: str | None = None, agent_id: AgentId | None = None, created_time: int, updated_time: int | None = None)` - Session domain entity with business logic
983
- - `update_name(new_name: str) -> None` - Updates session name with validation and sets updated_time
984
- - `mark_activity() -> None` - Marks session as having recent activity by updating timestamp
985
- - `can_be_deleted_by_user(user_id: UserId) -> bool` - Checks if user can delete this session
986
- - `can_be_accessed_by_user(user_id: UserId) -> bool` - Checks if user can access this session
987
- - `id: SessionId` - Unique session identifier
988
- - `user_id: UserId` - Owner user identifier
989
- - `name: str | None` - Optional session name
990
- - `agent_id: AgentId | None` - Optional associated agent identifier
991
- - `created_time: int` - Session creation timestamp
992
- - `updated_time: int | None` - Last update timestamp
993
-
994
- **Usage Examples:**
995
- ```python
996
- from solace_agent_mesh.gateway.http_sse.repository.entities import Session
997
-
998
- # Create a new session
999
- session = Session(
1000
- id="session_123",
1001
- user_id="user_456",
1002
- name="Customer Support Chat",
1003
- agent_id="agent_789",
1004
- created_time=1640995200000
1005
- )
1006
-
1007
- # Update session name
1008
- session.update_name("Updated Chat Name")
1009
-
1010
- # Mark activity
1011
- session.mark_activity()
1012
-
1013
- # Check permissions
1014
- if session.can_be_accessed_by_user("user_456"):
1015
- print("User can access this session")
1016
- ```
1017
-
1018
- ### session_history.py
1019
- **Purpose:** Defines a composite entity that combines a session with its message history
1020
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import SessionHistory`
1021
-
1022
- **Classes:**
1023
- - `SessionHistory(session: Session, messages: list[Message] = [], total_message_count: int = 0)` - Composite entity representing a session with its messages
1024
- - `session: Session` - The session entity
1025
- - `messages: list[Message]` - List of messages in the session
1026
- - `total_message_count: int` - Total count of messages (may exceed messages list length for pagination)
1027
-
1028
- **Usage Examples:**
1029
- ```python
1030
- from solace_agent_mesh.gateway.http_sse.repository.entities import SessionHistory, Session, Message
1031
- from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType
1032
-
1033
- # Create session history
1034
- session = Session(
1035
- id="session_123",
1036
- user_id="user_456",
1037
- created_time=1640995200000
1038
- )
1039
-
1040
- messages = [
1041
- Message(
1042
- id="msg_1",
1043
- session_id="session_123",
1044
- message="Hello",
1045
- sender_type=SenderType.USER,
1046
- sender_name="John",
1047
- created_time=1640995200000
1048
- )
1049
- ]
1050
-
1051
- history = SessionHistory(
1052
- session=session,
1053
- messages=messages,
1054
- total_message_count=1
1055
- )
1056
-
1057
- # Access session and messages
1058
- print(f"Session: {history.session.id}")
1059
- print(f"Message count: {len(history.messages)}")
1060
- print(f"Total messages: {history.total_message_count}")
1061
- ```
1062
-
1063
- ### task.py
1064
- **Purpose:** Defines the Task domain entity for tracking user tasks with token usage metrics
1065
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import Task`
1066
-
1067
- **Classes:**
1068
- - `Task(id: str, user_id: str, start_time: int, end_time: int | None = None, status: str | None = None, initial_request_text: str | None = None, total_input_tokens: int | None = None, total_output_tokens: int | None = None, total_cached_input_tokens: int | None = None, token_usage_details: dict | None = None)` - Task domain entity with token usage tracking
1069
- - `id: str` - Unique task identifier
1070
- - `user_id: str` - User who owns the task
1071
- - `start_time: int` - Task start timestamp
1072
- - `end_time: int | None` - Optional task end timestamp
1073
- - `status: str | None` - Optional task status
1074
- - `initial_request_text: str | None` - Optional initial request text
1075
- - `total_input_tokens: int | None` - Total input tokens used
1076
- - `total_output_tokens: int | None` - Total output tokens generated
1077
- - `total_cached_input_tokens: int | None` - Total cached input tokens used
1078
- - `token_usage_details: dict | None` - Detailed token usage information
1079
-
1080
- **Usage Examples:**
1081
- ```python
1082
- from solace_agent_mesh.gateway.http_sse.repository.entities import Task
1083
-
1084
- # Create a task
1085
- task = Task(
1086
- id="task_123",
1087
- user_id="user_456",
1088
- start_time=1640995200000,
1089
- status="in_progress",
1090
- initial_request_text="Help me with my order"
1091
- )
1092
-
1093
- # Task with token usage tracking
1094
- task_with_tokens = Task(
1095
- id="task_124",
1096
- user_id="user_456",
1097
- start_time=1640995200000,
1098
- end_time=1640995800000,
1099
- status="completed",
1100
- total_input_tokens=150,
1101
- total_output_tokens=300,
1102
- total_cached_input_tokens=50,
1103
- token_usage_details={"model": "gpt-4", "cost": 0.05}
1104
- )
1105
- ```
1106
-
1107
- ### task_event.py
1108
- **Purpose:** Defines the TaskEvent domain entity for tracking events related to tasks
1109
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.entities import TaskEvent`
1110
-
1111
- **Classes:**
1112
- - `TaskEvent(id: str, task_id: str, user_id: str | None = None, created_time: int, topic: str, direction: str, payload: dict[str, Any])` - TaskEvent domain entity
1113
- - `id: str` - Unique event identifier
1114
- - `task_id: str` - Associated task identifier
1115
- - `user_id: str | None` - Optional user identifier
1116
- - `created_time: int` - Event creation timestamp
1117
- - `topic: str` - Event topic
1118
- - `direction: str` - Event direction
1119
- - `payload: dict[str, Any]` - Event payload data
1120
-
1121
- **Usage Examples:**
1122
- ```python
1123
- from solace_agent_mesh.gateway.http_sse.repository.entities import TaskEvent
1124
-
1125
- # Create a task event
1126
- event = TaskEvent(
1127
- id="event_123",
1128
- task_id="task_456",
1129
- user_id="user_789",
1130
- created_time=1640995200000,
1131
- topic="task.status.changed",
1132
- direction="outbound",
1133
- payload={"status": "completed", "result": "success"}
1134
- )
1135
-
1136
- # Event without user
1137
- system_event = TaskEvent(
1138
- id="event_124",
1139
- task_id="task_456",
1140
- created_time=1640995200000,
1141
- topic="task.system.notification",
1142
- direction="inbound",
1143
- payload={"message": "Task processing started"}
1144
- )
1145
- ```
1146
-
1147
- ================================================================================
1148
-
1149
- ## Section 6: solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt
1150
-
1151
- **Source file:** `solace_agent_mesh/gateway/http_sse/repository/models/models_llm.txt`
1152
-
1153
- ## Quick Summary
1154
- This directory contains SQLAlchemy ORM models and Pydantic schemas for database persistence in the HTTP SSE gateway. It provides models for managing chat sessions, messages, tasks, task events, and user feedback with proper relationships and database schema definitions.
1155
-
1156
- ## Files Overview
1157
- - `__init__.py` - Package initialization exposing all SQLAlchemy and Pydantic models
1158
- - `base.py` - SQLAlchemy declarative base configuration
1159
- - `feedback_model.py` - FeedbackModel for storing user feedback on tasks
1160
- - `message_model.py` - MessageModel and Pydantic schemas for chat messages with session relationships
1161
- - `session_model.py` - SessionModel and Pydantic schemas for managing chat sessions
1162
- - `task_event_model.py` - TaskEventModel for storing A2A task events with task relationships
1163
- - `task_model.py` - TaskModel for managing tasks with event relationships and token usage tracking
1164
-
1165
- ## Developer API Reference
1166
-
1167
- ### __init__.py
1168
- **Purpose:** Package entry point that exposes all SQLAlchemy models and Pydantic schemas
1169
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models import Base, MessageModel, SessionModel, CreateMessageModel, UpdateMessageModel, CreateSessionModel, UpdateSessionModel, TaskEventModel, TaskModel, FeedbackModel`
1170
-
1171
- **Constants/Variables:**
1172
- - `__all__: List[str]` - Public API exports including all models and schemas
1173
-
1174
- ### base.py
1175
- **Purpose:** Provides the SQLAlchemy declarative base for all models
1176
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.base import Base`
1177
-
1178
- **Constants/Variables:**
1179
- - `Base: DeclarativeMeta` - SQLAlchemy declarative base class for all models
1180
-
1181
- **Usage Examples:**
1182
- ```python
1183
- from solace_agent_mesh.gateway.http_sse.repository.models.base import Base
1184
- from sqlalchemy import create_engine
1185
-
1186
- # Create all tables
1187
- engine = create_engine("sqlite:///example.db")
1188
- Base.metadata.create_all(engine)
1189
- ```
1190
-
1191
- ### feedback_model.py
1192
- **Purpose:** SQLAlchemy model for storing user feedback on tasks
1193
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.feedback_model import FeedbackModel`
1194
-
1195
- **Classes:**
1196
- - `FeedbackModel(Base)` - SQLAlchemy model for user feedback
1197
- - `id: Column[String]` - Primary key feedback identifier
1198
- - `session_id: Column[String]` - Session identifier
1199
- - `task_id: Column[String]` - Task identifier (indexed)
1200
- - `user_id: Column[String]` - User identifier (indexed)
1201
- - `rating: Column[String]` - Feedback rating (e.g., 'up', 'down')
1202
- - `comment: Column[Text]` - Optional feedback comment
1203
- - `created_time: Column[BigInteger]` - Creation timestamp in epoch milliseconds
1204
-
1205
- **Usage Examples:**
1206
- ```python
1207
- from solace_agent_mesh.gateway.http_sse.repository.models.feedback_model import FeedbackModel
1208
- from sqlalchemy.orm import sessionmaker
1209
-
1210
- # Create feedback
1211
- feedback = FeedbackModel(
1212
- id="feedback_123",
1213
- session_id="session_456",
1214
- task_id="task_789",
1215
- user_id="user_123",
1216
- rating="up",
1217
- comment="Great response!",
1218
- created_time=1640995200000
1219
- )
1220
-
1221
- # Add to database
1222
- Session = sessionmaker(bind=engine)
1223
- db_session = Session()
1224
- db_session.add(feedback)
1225
- db_session.commit()
1226
- ```
1227
-
1228
- ### message_model.py
1229
- **Purpose:** SQLAlchemy model and Pydantic schemas for storing chat messages with session relationships
1230
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.message_model import MessageModel, CreateMessageModel, UpdateMessageModel`
1231
-
1232
- **Classes:**
1233
- - `MessageModel(Base)` - SQLAlchemy model for chat messages
1234
- - `id: Column[String]` - Primary key message identifier
1235
- - `session_id: Column[String]` - Foreign key to sessions table with CASCADE delete
1236
- - `message: Column[Text]` - Message content
1237
- - `created_time: Column[BigInteger]` - Creation timestamp (auto-generated)
1238
- - `sender_type: Column[String]` - Type of message sender (max 50 chars)
1239
- - `sender_name: Column[String]` - Name of message sender (max 255 chars)
1240
- - `session: relationship` - SQLAlchemy relationship to SessionModel
1241
-
1242
- - `CreateMessageModel(BaseModel)` - Pydantic model for creating messages
1243
- - `id: str` - Message identifier
1244
- - `session_id: str` - Session identifier
1245
- - `message: str` - Message content
1246
- - `sender_type: str` - Sender type
1247
- - `sender_name: str` - Sender name
1248
- - `created_time: int` - Creation timestamp
1249
-
1250
- - `UpdateMessageModel(BaseModel)` - Pydantic model for updating messages
1251
- - `message: str` - Updated message content
1252
- - `sender_type: str` - Updated sender type
1253
- - `sender_name: str` - Updated sender name
1254
-
1255
- **Usage Examples:**
1256
- ```python
1257
- from solace_agent_mesh.gateway.http_sse.repository.models.message_model import MessageModel, CreateMessageModel
1258
- from sqlalchemy.orm import sessionmaker
1259
-
1260
- # Create using SQLAlchemy model
1261
- message = MessageModel(
1262
- id="msg_123",
1263
- session_id="session_456",
1264
- message="Hello, world!",
1265
- sender_type="user",
1266
- sender_name="John Doe"
1267
- )
1268
-
1269
- # Create using Pydantic model
1270
- create_data = CreateMessageModel(
1271
- id="msg_124",
1272
- session_id="session_456",
1273
- message="How are you?",
1274
- sender_type="user",
1275
- sender_name="John Doe",
1276
- created_time=1640995200000
1277
- )
1278
- ```
1279
-
1280
- ### session_model.py
1281
- **Purpose:** SQLAlchemy model and Pydantic schemas for managing chat sessions with message relationships
1282
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.session_model import SessionModel, CreateSessionModel, UpdateSessionModel`
1283
-
1284
- **Classes:**
1285
- - `SessionModel(Base)` - SQLAlchemy model for chat sessions
1286
- - `id: Column[String]` - Primary key session identifier
1287
- - `name: Column[String]` - Optional session name
1288
- - `user_id: Column[String]` - Required user identifier
1289
- - `agent_id: Column[String]` - Optional agent identifier
1290
- - `created_time: Column[BigInteger]` - Creation timestamp (auto-generated)
1291
- - `updated_time: Column[BigInteger]` - Last update timestamp (auto-updated)
1292
- - `messages: relationship` - SQLAlchemy relationship to MessageModel with cascade delete
1293
-
1294
- - `CreateSessionModel(BaseModel)` - Pydantic model for creating sessions
1295
- - `id: str` - Session identifier
1296
- - `name: str | None` - Optional session name
1297
- - `user_id: str` - User identifier
1298
- - `agent_id: str | None` - Optional agent identifier
1299
- - `created_time: int` - Creation timestamp
1300
- - `updated_time: int` - Update timestamp
1301
-
1302
- - `UpdateSessionModel(BaseModel)` - Pydantic model for updating sessions
1303
- - `name: str | None` - Optional updated session name
1304
- - `agent_id: str | None` - Optional updated agent identifier
1305
- - `updated_time: int` - Update timestamp
1306
-
1307
- **Usage Examples:**
1308
- ```python
1309
- from solace_agent_mesh.gateway.http_sse.repository.models.session_model import SessionModel, CreateSessionModel
1310
- from sqlalchemy.orm import sessionmaker
1311
-
1312
- # Create using SQLAlchemy model
1313
- session = SessionModel(
1314
- id="session_123",
1315
- name="My Chat Session",
1316
- user_id="user_456",
1317
- agent_id="agent_789"
1318
- )
1319
-
1320
- # Create using Pydantic model
1321
- create_data = CreateSessionModel(
1322
- id="session_124",
1323
- name="Another Session",
1324
- user_id="user_456",
1325
- agent_id="agent_789",
1326
- created_time=1640995200000,
1327
- updated_time=1640995200000
1328
- )
1329
-
1330
- # Access related messages
1331
- messages = session.messages # Returns list of MessageModel instances
1332
- ```
1333
-
1334
- ### task_event_model.py
1335
- **Purpose:** SQLAlchemy model for storing A2A task events with task relationships
1336
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.task_event_model import TaskEventModel`
1337
-
1338
- **Classes:**
1339
- - `TaskEventModel(Base)` - SQLAlchemy model for A2A task events
1340
- - `id: Column[String]` - Primary key event identifier
1341
- - `task_id: Column[String]` - Foreign key to tasks table with CASCADE delete (indexed)
1342
- - `user_id: Column[String]` - Optional user identifier (indexed)
1343
- - `created_time: Column[BigInteger]` - Creation timestamp in epoch milliseconds
1344
- - `topic: Column[Text]` - Event topic
1345
- - `direction: Column[String]` - Event direction (max 50 chars)
1346
- - `payload: Column[JSON]` - Event payload as JSON
1347
- - `task: relationship` - SQLAlchemy relationship to TaskModel
1348
-
1349
- **Usage Examples:**
1350
- ```python
1351
- from solace_agent_mesh.gateway.http_sse.repository.models.task_event_model import TaskEventModel
1352
- from sqlalchemy.orm import sessionmaker
1353
-
1354
- # Create a task event
1355
- event = TaskEventModel(
1356
- id="event_123",
1357
- task_id="task_456",
1358
- user_id="user_789",
1359
- created_time=1640995200000,
1360
- topic="agent/response",
1361
- direction="inbound",
1362
- payload={"message": "Task completed", "status": "success"}
1363
- )
1364
-
1365
- # Add to database
1366
- Session = sessionmaker(bind=engine)
1367
- db_session = Session()
1368
- db_session.add(event)
1369
- db_session.commit()
1370
- ```
1371
-
1372
- ### task_model.py
1373
- **Purpose:** SQLAlchemy model for managing tasks with event relationships and token usage tracking
1374
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel`
1375
-
1376
- **Classes:**
1377
- - `TaskModel(Base)` - SQLAlchemy model for tasks
1378
- - `id: Column[String]` - Primary key task identifier
1379
- - `user_id: Column[String]` - User identifier (indexed)
1380
- - `start_time: Column[BigInteger]` - Task start timestamp in epoch milliseconds
1381
- - `end_time: Column[BigInteger]` - Optional task end timestamp
1382
- - `status: Column[String]` - Optional task status
1383
- - `initial_request_text: Column[Text]` - Optional initial request text (indexed)
1384
- - `total_input_tokens: Column[Integer]` - Optional total input tokens used
1385
- - `total_output_tokens: Column[Integer]` - Optional total output tokens used
1386
- - `total_cached_input_tokens: Column[Integer]` - Optional total cached input tokens
1387
- - `token_usage_details: Column[JSON]` - Optional detailed token usage information
1388
- - `events: relationship` - SQLAlchemy relationship to TaskEventModel with cascade delete
1389
-
1390
- **Usage Examples:**
1391
- ```python
1392
- from solace_agent_mesh.gateway.http_sse.repository.models.task_model import TaskModel
1393
- from sqlalchemy.orm import sessionmaker
1394
-
1395
- # Create a new task with token tracking
1396
- task = TaskModel(
1397
- id="task_123",
1398
- user_id="user_456",
1399
- start_time=1640995200000,
1400
- status="in_progress",
1401
- initial_request_text="Please help me with this task",
1402
- total_input_tokens=150,
1403
- total_output_tokens=300,
1404
- total_cached_input_tokens=50,
1405
- token_usage_details={"model": "gpt-4", "breakdown": {"reasoning": 200, "response": 100}}
1406
- )
1407
-
1408
- # Add to database
1409
- Session = sessionmaker(bind=engine)
1410
- db_session = Session()
1411
- db_session.add(task)
1412
- db_session.commit()
1413
-
1414
- # Access related events
1415
- events = task.events # Returns list of TaskEventModel instances
1416
- ```
1417
-
1418
- ================================================================================
1419
-
1420
- ## Section 7: solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt
1421
-
1422
- **Source file:** `solace_agent_mesh/gateway/http_sse/repository/repository_llm.txt`
1423
-
1424
- ## Quick Summary
1425
-
1426
- The repository directory implements the data access layer for the HTTP SSE gateway using the Repository pattern. It provides a clean separation between domain entities and database persistence through SQLAlchemy ORM models. The architecture consists of abstract interfaces, concrete implementations, domain entities with business logic, and SQLAlchemy models for database operations. The two main subdirectories (entities and models) work together to provide a complete data persistence solution for chat sessions, messages, tasks, feedback, and events.
1427
-
1428
- ## Files and Subdirectories Overview
1429
-
1430
- **Direct files:**
1431
- - `__init__.py` - Main package exports for repository interfaces, implementations, entities, and models
1432
- - `interfaces.py` - Abstract repository interfaces defining data access contracts for sessions, messages, tasks, and feedback
1433
- - `message_repository.py` - SQLAlchemy implementation of message data access operations
1434
- - `session_repository.py` - SQLAlchemy implementation of session data access operations
1435
- - `feedback_repository.py` - SQLAlchemy implementation of feedback data access operations
1436
- - `task_repository.py` - SQLAlchemy implementation of task data access operations
1437
-
1438
- **Subdirectories:**
1439
- - `entities/` - Domain entities with business logic for sessions, messages, tasks, feedback, and events
1440
- - `models/` - SQLAlchemy ORM models for database persistence and schema definition
1441
-
1442
- ## Developer API Reference
1443
-
1444
- ### Direct Files
1445
-
1446
- #### __init__.py
1447
- **Purpose:** Central package exports for all repository components
1448
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository import IMessageRepository, ISessionRepository, MessageRepository, SessionRepository, Session, Message, SessionHistory, Base, MessageModel, SessionModel`
1449
-
1450
- **Exports:**
1451
- - `IMessageRepository` - Message repository interface
1452
- - `ISessionRepository` - Session repository interface
1453
- - `MessageRepository` - Message repository implementation
1454
- - `SessionRepository` - Session repository implementation
1455
- - `Message` - Message domain entity
1456
- - `Session` - Session domain entity
1457
- - `SessionHistory` - Session with messages composite entity
1458
- - `Base` - SQLAlchemy declarative base
1459
- - `MessageModel` - SQLAlchemy message model
1460
- - `SessionModel` - SQLAlchemy session model
1461
-
1462
- #### interfaces.py
1463
- **Purpose:** Defines abstract repository interfaces for data access contracts
1464
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.interfaces import ISessionRepository, IMessageRepository, ITaskRepository, IFeedbackRepository`
1465
-
1466
- **Classes:**
1467
- - `ISessionRepository(ABC)` - Abstract interface for session data operations
1468
- - `find_by_user(user_id: UserId, pagination: PaginationInfo | None = None) -> list[Session]` - Find all sessions for a user
1469
- - `count_by_user(user_id: UserId) -> int` - Count total sessions for a user
1470
- - `find_user_session(session_id: SessionId, user_id: UserId) -> Session | None` - Find specific user session
1471
- - `save(session: Session) -> Session` - Save or update a session
1472
- - `delete(session_id: SessionId, user_id: UserId) -> bool` - Delete user session
1473
- - `find_user_session_with_messages(session_id: SessionId, user_id: UserId, pagination: PaginationInfo | None = None) -> tuple[Session, list[Message]] | None` - Find session with messages
1474
-
1475
- - `IMessageRepository(ABC)` - Abstract interface for message data operations
1476
- - `find_by_session(session_id: SessionId, pagination: PaginationInfo | None = None) -> list[Message]` - Find messages in session
1477
- - `save(message: Message) -> Message` - Save or update a message
1478
- - `delete_by_session(session_id: SessionId) -> bool` - Delete all session messages
1479
-
1480
- - `ITaskRepository(ABC)` - Abstract interface for task data operations
1481
- - `save_task(task: Task) -> Task` - Create or update a task
1482
- - `save_event(event: TaskEvent) -> TaskEvent` - Save a task event
1483
- - `find_by_id(task_id: str) -> Task | None` - Find a task by its ID
1484
- - `find_by_id_with_events(task_id: str) -> tuple[Task, list[TaskEvent]] | None` - Find a task with all its events
1485
- - `search(user_id: UserId, start_date: int | None = None, end_date: int | None = None, search_query: str | None = None, pagination: PaginationParams | None = None) -> list[Task]` - Search for tasks with filters
1486
- - `delete_tasks_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete tasks older than cutoff time
1487
-
1488
- - `IFeedbackRepository(ABC)` - Abstract interface for feedback data operations
1489
- - `save(feedback: Feedback) -> Feedback` - Save feedback
1490
- - `delete_feedback_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete feedback older than cutoff time
1491
-
1492
- #### message_repository.py
1493
- **Purpose:** SQLAlchemy implementation of message repository interface
1494
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.message_repository import MessageRepository`
1495
-
1496
- **Classes:**
1497
- - `MessageRepository(IMessageRepository)` - SQLAlchemy message repository implementation
1498
- - `__init__(db: DBSession)` - Initialize with database session
1499
- - `find_by_session(session_id: SessionId, pagination: PaginationInfo | None = None) -> list[Message]` - Find messages in session with pagination
1500
- - `save(message: Message) -> Message` - Save or update message in database
1501
- - `delete_by_session(session_id: SessionId) -> bool` - Delete all messages in session
1502
- - `_convert_model_to_entity(model: MessageModel) -> Message` - Convert SQLAlchemy model to domain entity
1503
-
1504
- #### session_repository.py
1505
- **Purpose:** SQLAlchemy implementation of session repository interface
1506
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.session_repository import SessionRepository`
1507
-
1508
- **Classes:**
1509
- - `SessionRepository(ISessionRepository)` - SQLAlchemy session repository implementation
1510
- - `__init__(db: DBSession)` - Initialize with database session
1511
- - `find_by_user(user_id: UserId, pagination: PaginationInfo | None = None) -> list[Session]` - Find user sessions with pagination
1512
- - `count_by_user(user_id: UserId) -> int` - Count total sessions for a user
1513
- - `find_user_session(session_id: SessionId, user_id: UserId) -> Session | None` - Find specific user session
1514
- - `save(session: Session) -> Session` - Save or update session in database
1515
- - `delete(session_id: SessionId, user_id: UserId) -> bool` - Delete user session
1516
- - `find_user_session_with_messages(session_id: SessionId, user_id: UserId, pagination: PaginationInfo | None = None) -> tuple[Session, list[Message]] | None` - Find session with messages
1517
- - `_message_model_to_entity(model: MessageModel) -> Message` - Convert message model to entity
1518
-
1519
- #### feedback_repository.py
1520
- **Purpose:** SQLAlchemy implementation of feedback repository interface
1521
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.feedback_repository import FeedbackRepository`
1522
-
1523
- **Classes:**
1524
- - `FeedbackRepository(IFeedbackRepository)` - SQLAlchemy feedback repository implementation
1525
- - `__init__(db: DBSession)` - Initialize with database session
1526
- - `save(feedback: Feedback) -> Feedback` - Save feedback to database
1527
- - `delete_feedback_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete feedback older than cutoff time using batch deletion
1528
- - `_model_to_entity(model: FeedbackModel) -> Feedback` - Convert SQLAlchemy model to domain entity
1529
-
1530
- #### task_repository.py
1531
- **Purpose:** SQLAlchemy implementation of task repository interface
1532
- **Import:** `from solace_agent_mesh.gateway.http_sse.repository.task_repository import TaskRepository`
1533
-
1534
- **Classes:**
1535
- - `TaskRepository(ITaskRepository)` - SQLAlchemy task repository implementation
1536
- - `__init__(db: DBSession)` - Initialize with database session
1537
- - `save_task(task: Task) -> Task` - Create or update a task
1538
- - `save_event(event: TaskEvent) -> TaskEvent` - Save a task event
1539
- - `find_by_id(task_id: str) -> Task | None` - Find a task by its ID
1540
- - `find_by_id_with_events(task_id: str) -> tuple[Task, list[TaskEvent]] | None` - Find a task with all its events
1541
- - `search(user_id: UserId, start_date: int | None = None, end_date: int | None = None, search_query: str | None = None, pagination: PaginationParams | None = None) -> list[Task]` - Search for tasks with filters
1542
- - `delete_tasks_older_than(cutoff_time_ms: int, batch_size: int) -> int` - Delete tasks older than cutoff time using batch deletion
1543
- - `_task_model_to_entity(model: TaskModel) -> Task` - Convert SQLAlchemy task model to domain entity
1544
- - `_event_model_to_entity(model: TaskEventModel) -> TaskEvent` - Convert SQLAlchemy event model to domain entity
1545
-
1546
- ### Subdirectory APIs
1547
-
1548
- #### entities/
1549
- **Purpose:** Provides domain entities with business logic for sessions, messages, tasks, feedback, and events
1550
- **Key Exports:** Message, Session, SessionHistory, Task, TaskEvent, Feedback
1551
- **Import Examples:**
1552
- ```python
1553
- from solace_agent_mesh.gateway.http_sse.repository.entities import Message, Session, SessionHistory, Task, TaskEvent, Feedback
1554
- ```
1555
-
1556
- #### models/
1557
- **Purpose:** Provides SQLAlchemy ORM models for database persistence and schema definition
1558
- **Key Exports:** Base, MessageModel, SessionModel, TaskModel, TaskEventModel, FeedbackModel
1559
- **Import Examples:**
1560
- ```python
1561
- from solace_agent_mesh.gateway.http_sse.repository.models import Base, MessageModel, SessionModel, TaskModel, TaskEventModel, FeedbackModel
1562
- ```
1563
-
1564
- ## Complete Usage Guide
1565
-
1566
- ### 1. Setting Up the Repository Layer
1567
-
1568
- ```python
1569
- from sqlalchemy import create_engine
1570
- from sqlalchemy.orm import sessionmaker
1571
- from solace_agent_mesh.gateway.http_sse.repository import (
1572
- Base, MessageRepository, SessionRepository, TaskRepository, FeedbackRepository
1573
- )
1574
-
1575
- # Create database engine and session
1576
- engine = create_engine("sqlite:///chat.db")
1577
- Base.metadata.create_all(engine)
1578
- Session = sessionmaker(bind=engine)
1579
- db_session = Session()
1580
-
1581
- # Initialize repositories
1582
- message_repo = MessageRepository(db_session)
1583
- session_repo = SessionRepository(db_session)
1584
- task_repo = TaskRepository(db_session)
1585
- feedback_repo = FeedbackRepository(db_session)
1586
- ```
1587
-
1588
- ### 2. Working with Sessions
1589
-
1590
- ```python
1591
- from solace_agent_mesh.gateway.http_sse.repository.entities import Session
1592
- from solace_agent_mesh.gateway.http_sse.shared.types import PaginationInfo
1593
- import time
1594
-
1595
- # Create a new session
1596
- session = Session(
1597
- id="session_123",
1598
- user_id="user_456",
1599
- name="Customer Support Chat",
1600
- agent_id="agent_789",
1601
- created_time=int(time.time() * 1000)
1602
- )
1603
-
1604
- # Save session
1605
- saved_session = session_repo.save(session)
1606
-
1607
- # Find user sessions with pagination
1608
- pagination = PaginationInfo(page=1, page_size=10)
1609
- user_sessions = session_repo.find_by_user("user_456", pagination)
1610
-
1611
- # Count total sessions for user
1612
- total_sessions = session_repo.count_by_user("user_456")
1613
-
1614
- # Find specific session
1615
- found_session = session_repo.find_user_session("session_123", "user_456")
1616
-
1617
- # Update session
1618
- if found_session:
1619
- found_session.update_name("Updated Chat Name")
1620
- session_repo.save(found_session)
1621
- ```
1622
-
1623
- ### 3. Working with Messages
1624
-
1625
- ```python
1626
- from solace_agent_mesh.gateway.http_sse.repository.entities import Message
1627
- from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType, MessageType
1628
-
1629
- # Create a new message
1630
- message = Message(
1631
- id="msg_123",
1632
- session_id="session_123",
1633
- message="Hello, how can I help you today?",
1634
- sender_type=SenderType.AGENT,
1635
- sender_name="Support Agent",
1636
- message_type=MessageType.TEXT,
1637
- created_time=int(time.time() * 1000)
1638
- )
1639
-
1640
- # Validate and save message
1641
- message.validate_message_content()
1642
- saved_message = message_repo.save(message)
1643
-
1644
- # Find messages in session
1645
- session_messages = message_repo.find_by_session("session_123", pagination)
1646
-
1647
- # Check message properties
1648
- if message.is_from_agent():
1649
- print("Message from agent")
1650
- ```
1651
-
1652
- ### 4. Working with Tasks and Events
1653
-
1654
- ```python
1655
- from solace_agent_mesh.gateway.http_sse.repository.entities import Task, TaskEvent
1656
-
1657
- # Create a new task
1658
- task = Task(
1659
- id="task_123",
1660
- user_id="user_456",
1661
- start_time=int(time.time() * 1000),
1662
- status="in_progress",
1663
- initial_request_text="Help me with my order"
1664
- )
1665
-
1666
- # Save task
1667
- saved_task = task_repo.save_task(task)
1668
-
1669
- # Create task event
1670
- event = TaskEvent(
1671
- id="event_123",
1672
- task_id="task_123",
1673
- user_id="user_456",
1674
- created_time=int(time.time() * 1000),
1675
- topic="task.status.changed",
1676
- direction="outbound",
1677
- payload={"status": "completed", "result": "success"}
1678
- )
1679
-
1680
- # Save event
1681
- saved_event = task_repo.save_event(event)
1682
-
1683
- # Find task with events
1684
- result = task_repo.find_by_id_with_events("task_123")
1685
- if result:
1686
- task, events = result
1687
- print(f"Task {task.id} has {len(events)} events")
1688
-
1689
- # Search tasks
1690
- from solace_agent_mesh.gateway.http_sse.shared.types import PaginationParams
1691
- pagination_params = PaginationParams(page=1, page_size=10)
1692
- tasks = task_repo.search(
1693
- user_id="user_456",
1694
- search_query="order",
1695
- pagination=pagination_params
1696
- )
1697
- ```
1698
-
1699
- ### 5. Working with Feedback
1700
-
1701
- ```python
1702
- from solace_agent_mesh.gateway.http_sse.repository.entities import Feedback
1703
-
1704
- # Create feedback
1705
- feedback = Feedback(
1706
- id="feedback_123",
1707
- session_id="session_123",
1708
- task_id="task_123",
1709
- user_id="user_456",
1710
- rating="up",
1711
- comment="Great service!",
1712
- created_time=int(time.time() * 1000)
1713
- )
1714
-
1715
- # Save feedback
1716
- saved_feedback = feedback_repo.save(feedback)
1717
- ```
1718
-
1719
- ### 6. Working with Session History (Combined Operations)
1720
-
1721
- ```python
1722
- from solace_agent_mesh.gateway.http_sse.repository.entities import SessionHistory
1723
-
1724
- # Get session with messages in one operation
1725
- result = session_repo.find_user_session_with_messages(
1726
- "session_123", "user_456", pagination
1727
- )
1728
-
1729
- if result:
1730
- session, messages = result
1731
-
1732
- # Create session history object
1733
- history = SessionHistory(
1734
- session=session,
1735
- messages=messages,
1736
- total_message_count=len(messages)
1737
- )
1738
-
1739
- print(f"Session: {history.session.name}")
1740
- print(f"Messages: {len(history.messages)}")
1741
- ```
1742
-
1743
- ### 7. Using Repository Interfaces for Dependency Injection
1744
-
1745
- ```python
1746
- from solace_agent_mesh.gateway.http_sse.repository.interfaces import (
1747
- ISessionRepository, IMessageRepository, ITaskRepository, IFeedbackRepository
1748
- )
1749
-
1750
- class ChatService:
1751
- def __init__(
1752
- self,
1753
- session_repo: ISessionRepository,
1754
- message_repo: IMessageRepository,
1755
- task_repo: ITaskRepository,
1756
- feedback_repo: IFeedbackRepository
1757
- ):
1758
- self.session_repo = session_repo
1759
- self.message_repo = message_repo
1760
- self.task_repo = task_repo
1761
- self.feedback_
1762
-
1763
- ================================================================================
1764
-
1765
- ## Section 8: solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt
1766
-
1767
- **Source file:** `solace_agent_mesh/gateway/http_sse/routers/dto/dto_llm.txt`
1768
-
1769
- # DEVELOPER GUIDE: dto
1770
-
1771
- ## Quick Summary
1772
- The `dto` directory contains Data Transfer Objects (DTOs) for API contract definition and validation in the HTTP SSE gateway. It's organized into two main subdirectories: `requests` for incoming API request validation using Pydantic models, and `responses` for structured API response formatting with automatic timestamp conversion. The DTOs primarily focus on session management operations and provide type-safe interfaces for API endpoints.
1773
-
1774
- ## Files and Subdirectories Overview
1775
- - **Direct files:**
1776
- - `__init__.py` - Main module exports for requests and responses submodules
1777
- - **Subdirectories:**
1778
- - `requests/` - Request DTOs for API endpoint validation (session CRUD operations)
1779
- - `responses/` - Response DTOs with automatic timestamp serialization and field aliasing
1780
-
1781
- ## Developer API Reference
1782
-
1783
- ### Direct Files
1784
-
1785
- #### __init__.py
1786
- **Purpose:** Main entry point that exports the requests and responses submodules
1787
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.dto import requests, responses`
1788
-
1789
- **Exports:**
1790
- - `requests` - Module containing all request DTOs
1791
- - `responses` - Module containing all response DTOs
1792
-
1793
- ### Subdirectory APIs
1794
-
1795
- #### requests/
1796
- **Purpose:** Provides Pydantic models for validating incoming API requests, specifically for session management operations
1797
- **Key Exports:** GetSessionsRequest, GetSessionRequest, GetSessionHistoryRequest, UpdateSessionRequest, DeleteSessionRequest
1798
- **Import Examples:**
1799
- ```python
1800
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests import (
1801
- GetSessionRequest,
1802
- GetSessionHistoryRequest,
1803
- UpdateSessionRequest
1804
- )
1805
- ```
1806
-
1807
- #### responses/
1808
- **Purpose:** Provides structured response DTOs with automatic timestamp conversion and field aliasing for API consistency
1809
- **Key Exports:** MessageResponse, SessionResponse, SessionListResponse, BaseTimestampResponse
1810
- **Import Examples:**
1811
- ```python
1812
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import (
1813
- MessageResponse,
1814
- SessionResponse,
1815
- SessionListResponse
1816
- )
1817
- ```
1818
-
1819
- ## Complete Usage Guide
1820
-
1821
- ### 1. Basic Imports and Setup
1822
-
1823
- ```python
1824
- # Import the main dto modules
1825
- from solace_agent_mesh.gateway.http_sse.routers.dto import requests, responses
1826
-
1827
- # Or import specific DTOs directly
1828
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests import (
1829
- GetSessionRequest,
1830
- GetSessionHistoryRequest,
1831
- UpdateSessionRequest
1832
- )
1833
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import (
1834
- SessionResponse,
1835
- MessageResponse,
1836
- SessionListResponse
1837
- )
1838
- ```
1839
-
1840
- ### 2. Working with Request DTOs
1841
-
1842
- ```python
1843
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests import (
1844
- GetSessionRequest,
1845
- GetSessionHistoryRequest,
1846
- UpdateSessionRequest
1847
- )
1848
- from pydantic import ValidationError
1849
-
1850
- # Create a request to get a specific session
1851
- def get_session(session_id: str, user_id: str):
1852
- try:
1853
- request = GetSessionRequest(
1854
- session_id=session_id,
1855
- user_id=user_id
1856
- )
1857
- return request
1858
- except ValidationError as e:
1859
- print(f"Invalid request parameters: {e}")
1860
- return None
1861
-
1862
- # Create a request to get session history with pagination
1863
- def get_session_history(session_id: str, user_id: str, page: int = 1, size: int = 20):
1864
- try:
1865
- request = GetSessionHistoryRequest(
1866
- session_id=session_id,
1867
- user_id=user_id,
1868
- pagination={"page": page, "size": size}
1869
- )
1870
- return request
1871
- except ValidationError as e:
1872
- print(f"Validation failed: {e}")
1873
- return None
1874
-
1875
- # Create a request to update session name
1876
- def update_session_name(session_id: str, user_id: str, new_name: str):
1877
- try:
1878
- request = UpdateSessionRequest(
1879
- session_id=session_id,
1880
- user_id=user_id,
1881
- name=new_name # Automatically validated (1-255 characters)
1882
- )
1883
- return request
1884
- except ValidationError as e:
1885
- print(f"Validation failed: {e}")
1886
- return None
1887
- ```
1888
-
1889
- ### 3. Working with Response DTOs
1890
-
1891
- ```python
1892
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import (
1893
- SessionResponse,
1894
- MessageResponse,
1895
- SessionListResponse
1896
- )
1897
- from solace_agent_mesh.gateway.http_sse.shared.enums import MessageType, SenderType
1898
- import time
1899
-
1900
- # Create session responses
1901
- def create_session_response(session_data: dict) -> SessionResponse:
1902
- return SessionResponse(
1903
- id=session_data["id"],
1904
- user_id=session_data["user_id"],
1905
- name=session_data.get("name"),
1906
- agent_id=session_data.get("agent_id"),
1907
- created_time=int(time.time() * 1000), # Current time in epoch ms
1908
- updated_time=session_data.get("updated_time")
1909
- )
1910
-
1911
- # Create message responses
1912
- def create_message_response(message_data: dict) -> MessageResponse:
1913
- return MessageResponse(
1914
- id=message_data["id"],
1915
- session_id=message_data["session_id"],
1916
- message=message_data["message"],
1917
- sender_type=SenderType.USER,
1918
- sender_name=message_data["sender_name"],
1919
- message_type=MessageType.TEXT,
1920
- created_time=int(time.time() * 1000)
1921
- )
1922
-
1923
- # Create paginated session list responses
1924
- def create_session_list_response(sessions: list, total: int) -> SessionListResponse:
1925
- session_responses = [create_session_response(session) for session in sessions]
1926
- return SessionListResponse(
1927
- sessions=session_responses,
1928
- pagination={"page": 1, "size": len(sessions), "total_pages": 1},
1929
- total_count=total
1930
- )
1931
- ```
1932
-
1933
- ### 4. Complete API Endpoint Example
1934
-
1935
- ```python
1936
- from fastapi import APIRouter, HTTPException
1937
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests import (
1938
- GetSessionRequest,
1939
- GetSessionHistoryRequest,
1940
- UpdateSessionRequest
1941
- )
1942
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import (
1943
- SessionResponse,
1944
- MessageResponse,
1945
- SessionListResponse
1946
- )
1947
-
1948
- router = APIRouter()
1949
-
1950
- @router.get("/sessions/{session_id}")
1951
- async def get_session(session_id: str, user_id: str) -> SessionResponse:
1952
- """Get a specific session"""
1953
-
1954
- # Create and validate request DTO
1955
- request = GetSessionRequest(
1956
- session_id=session_id,
1957
- user_id=user_id
1958
- )
1959
-
1960
- # Fetch data (mock implementation)
1961
- session_data = fetch_session(request)
1962
-
1963
- # Return structured response with automatic timestamp conversion
1964
- return SessionResponse(
1965
- id=session_data["id"],
1966
- user_id=session_data["user_id"],
1967
- name=session_data["name"],
1968
- created_time=session_data["created_time"]
1969
- )
1970
-
1971
- @router.get("/sessions/{session_id}/history")
1972
- async def get_session_history(
1973
- session_id: str,
1974
- user_id: str,
1975
- page: int = 1,
1976
- size: int = 20
1977
- ) -> list[MessageResponse]:
1978
- """Get session message history"""
1979
-
1980
- # Validate request using DTO
1981
- request = GetSessionHistoryRequest(
1982
- session_id=session_id,
1983
- user_id=user_id,
1984
- pagination={"page": page, "size": size}
1985
- )
1986
-
1987
- # Fetch messages (mock implementation)
1988
- messages_data = fetch_session_messages(request)
1989
-
1990
- # Return response DTOs with automatic field aliasing
1991
- return [
1992
- MessageResponse(
1993
- id=msg["id"],
1994
- session_id=msg["session_id"],
1995
- message=msg["message"],
1996
- sender_type=msg["sender_type"],
1997
- sender_name=msg["sender_name"],
1998
- message_type=msg["message_type"],
1999
- created_time=msg["created_time"]
2000
- )
2001
- for msg in messages_data
2002
- ]
2003
-
2004
- @router.put("/sessions/{session_id}")
2005
- async def update_session(
2006
- session_id: str,
2007
- user_id: str,
2008
- name: str
2009
- ) -> SessionResponse:
2010
- """Update session name"""
2011
-
2012
- # Validate request using DTO
2013
- try:
2014
- request = UpdateSessionRequest(
2015
- session_id=session_id,
2016
- user_id=user_id,
2017
- name=name
2018
- )
2019
- except ValidationError as e:
2020
- raise HTTPException(status_code=400, detail=str(e))
2021
-
2022
- # Update session (mock implementation)
2023
- updated_session = update_session_in_db(request)
2024
-
2025
- # Return response DTO with automatic field aliasing
2026
- return SessionResponse(
2027
- id=updated_session["id"],
2028
- user_id=updated_session["user_id"],
2029
- name=updated_session["name"],
2030
- created_time=updated_session["created_time"],
2031
- updated_time=updated_session["updated_time"]
2032
- )
2033
- ```
2034
-
2035
- ### 5. JSON Serialization with Automatic Timestamp Conversion
2036
-
2037
- ```python
2038
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import SessionResponse, MessageResponse
2039
- from solace_agent_mesh.gateway.http_sse.shared.enums import MessageType, SenderType
2040
- import json
2041
-
2042
- # Create a session response
2043
- session = SessionResponse(
2044
- id="sess_123",
2045
- user_id="user_456",
2046
- name="My Session",
2047
- created_time=1640995200000, # Epoch milliseconds
2048
- updated_time=1640995260000
2049
- )
2050
-
2051
- # Automatic conversion to ISO strings in JSON output
2052
- json_output = session.model_dump_json()
2053
- print(json_output)
2054
- # Output: {
2055
- # "id": "sess_123",
2056
- # "userId": "user_456", # Note the camelCase aliasing
2057
- # "name": "My Session",
2058
- # "createdTime": "2022-01-01T00:00:00Z", # Converted to ISO string
2059
- # "updatedTime": "2022-01-01T00:01:00Z"
2060
- # }
2061
-
2062
- # Create a message response with field aliasing
2063
- message = MessageResponse(
2064
- id="msg_789",
2065
- session_id="sess_123",
2066
- message="Hello world",
2067
- sender_type=SenderType.USER,
2068
- sender_name="John Doe",
2069
- message_type=MessageType.TEXT,
2070
- created_time=1640995200000
2071
- )
2072
-
2073
- # Get dict with converted timestamps and aliased fields
2074
- dict_output = message.model_dump()
2075
- print(dict_output["sessionId"]) # "sess_123" (camelCase alias)
2076
- print(dict_output["senderType"]) # SenderType.USER (camelCase alias)
2077
- print(dict_output["createdTime"]) # "2022-01-01T00:00:00Z" (converted timestamp)
2078
- ```
2079
-
2080
- ### 6. Custom Response Classes Using Base
2081
-
2082
- ```python
2083
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses.base_responses import BaseTimestampResponse
2084
-
2085
- class CustomResponse(BaseTimestampResponse):
2086
- """Custom response with automatic timestamp handling"""
2087
- name: str
2088
- status: str
2089
- created_time: int
2090
- last_accessed: int | None = None
2091
-
2092
- class Config:
2093
- # Add field aliases if needed
2094
- alias_generator = lambda field_name: ''.join(
2095
- word.capitalize() if i > 0 else word
2096
- for i, word in enumerate(field_name.split('_'))
2097
- )
2098
-
2099
- # Usage
2100
- custom_response = CustomResponse(
2101
- name="Test Item",
2102
- status="active",
2103
- created_time=1640995200000,
2104
- last_accessed=1640995300000
2105
- )
2106
-
2107
- # Automatic timestamp conversion in JSON
2108
- json_data = custom_response.model_dump_json()
2109
- # Fields like created_time become ISO strings automatically
2110
- ```
2111
-
2112
- This comprehensive guide shows how the `dto` directory provides a complete type-safe API contract system with automatic validation for requests and structured responses with timestamp conversion for the HTTP SSE gateway.
2113
-
2114
- ================================================================================
2115
-
2116
- ## Section 9: solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt
2117
-
2118
- **Source file:** `solace_agent_mesh/gateway/http_sse/routers/dto/requests/requests_llm.txt`
2119
-
2120
- # DEVELOPER GUIDE: requests
2121
-
2122
- ## Quick Summary
2123
- This directory contains request Data Transfer Objects (DTOs) for API endpoints, specifically focused on session management operations. These Pydantic models define the structure and validation rules for incoming API requests.
2124
-
2125
- ## Files Overview
2126
- - `__init__.py` - Exports all session-related request DTOs for easy importing
2127
- - `session_requests.py` - Defines request DTOs for session CRUD operations (get, update, history retrieval)
2128
-
2129
- ## Developer API Reference
2130
-
2131
- ### __init__.py
2132
- **Purpose:** Provides centralized imports for all request DTOs
2133
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.dto.requests import GetSessionRequest, GetSessionHistoryRequest, UpdateSessionRequest`
2134
-
2135
- **Usage Examples:**
2136
- ```python
2137
- # Import all session request DTOs
2138
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests import (
2139
- GetSessionRequest,
2140
- GetSessionHistoryRequest,
2141
- UpdateSessionRequest
2142
- )
2143
- ```
2144
-
2145
- ### session_requests.py
2146
- **Purpose:** Defines Pydantic models for session-related API request validation
2147
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.dto.requests.session_requests import GetSessionRequest, GetSessionHistoryRequest, UpdateSessionRequest`
2148
-
2149
- **Classes:**
2150
- - `GetSessionRequest(session_id: SessionId, user_id: UserId)` - Request DTO for retrieving a specific session by ID
2151
- - `GetSessionHistoryRequest(session_id: SessionId, user_id: UserId, pagination: Optional[PaginationInfo] = None)` - Request DTO for retrieving session message history with optional pagination
2152
- - `UpdateSessionRequest(session_id: SessionId, user_id: UserId, name: str)` - Request DTO for updating session details with validation (name must be 1-255 characters)
2153
-
2154
- **Usage Examples:**
2155
- ```python
2156
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests.session_requests import (
2157
- GetSessionRequest,
2158
- GetSessionHistoryRequest,
2159
- UpdateSessionRequest
2160
- )
2161
- from pydantic import ValidationError
2162
-
2163
- # Create a request to get a specific session
2164
- get_session_req = GetSessionRequest(
2165
- session_id="session456",
2166
- user_id="user123"
2167
- )
2168
-
2169
- # Create a request to get session history with pagination
2170
- get_history_req = GetSessionHistoryRequest(
2171
- session_id="session456",
2172
- user_id="user123",
2173
- pagination={"page": 1, "size": 20}
2174
- )
2175
-
2176
- # Create a request to update a session name
2177
- update_req = UpdateSessionRequest(
2178
- session_id="session456",
2179
- user_id="user123",
2180
- name="My Updated Session"
2181
- )
2182
-
2183
- # Validate request data from dictionary
2184
- request_data = {
2185
- "session_id": "session789",
2186
- "user_id": "user456",
2187
- "name": "New Session Name"
2188
- }
2189
-
2190
- try:
2191
- validated_request = UpdateSessionRequest(**request_data)
2192
- print(f"Valid request: {validated_request}")
2193
- except ValidationError as e:
2194
- print(f"Validation failed: {e}")
2195
-
2196
- # Access validated fields
2197
- print(f"Session ID: {update_req.session_id}")
2198
- print(f"User ID: {update_req.user_id}")
2199
- print(f"New name: {update_req.name}")
2200
- ```
2201
-
2202
- ================================================================================
2203
-
2204
- ## Section 10: solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt
2205
-
2206
- **Source file:** `solace_agent_mesh/gateway/http_sse/routers/dto/responses/responses_llm.txt`
2207
-
2208
- # DEVELOPER GUIDE: responses
2209
-
2210
- ## Quick Summary
2211
- The `responses` directory contains Pydantic response DTOs (Data Transfer Objects) for API endpoints. It provides structured response models with automatic timestamp conversion from epoch milliseconds to ISO 8601 strings for JSON serialization.
2212
-
2213
- ## Files Overview
2214
- - `__init__.py` - Exports all response DTOs for easy importing
2215
- - `base_responses.py` - Base response class with automatic timestamp serialization
2216
- - `session_responses.py` - Session and message-related response DTOs
2217
-
2218
- ## Developer API Reference
2219
-
2220
- ### __init__.py
2221
- **Purpose:** Central import point for all response DTOs
2222
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.dto.responses import MessageResponse, SessionResponse, SessionListResponse`
2223
-
2224
- ### base_responses.py
2225
- **Purpose:** Provides base response class with automatic timestamp field conversion
2226
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.dto.responses.base_responses import BaseTimestampResponse`
2227
-
2228
- **Classes:**
2229
- - `BaseTimestampResponse(BaseModel)` - Base class for responses with timestamp fields that auto-converts epoch ms to ISO strings
2230
- - `model_dump(**kwargs) -> dict[str, Any]` - Converts timestamp fields to ISO strings in output
2231
- - `model_dump_json(**kwargs) -> str` - Serializes to JSON with timestamp conversion
2232
-
2233
- **Usage Examples:**
2234
- ```python
2235
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses.base_responses import BaseTimestampResponse
2236
-
2237
- class MyResponse(BaseTimestampResponse):
2238
- name: str
2239
- created_time: int # Will be auto-converted to ISO string in JSON output
2240
- updated_time: int | None = None
2241
-
2242
- # Usage
2243
- response = MyResponse(name="test", created_time=1640995200000)
2244
- json_data = response.model_dump() # created_time becomes ISO string
2245
- ```
2246
-
2247
- ### session_responses.py
2248
- **Purpose:** Session and message response DTOs with field aliasing for API consistency
2249
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.dto.responses import MessageResponse, SessionResponse, SessionListResponse`
2250
-
2251
- **Classes:**
2252
- - `MessageResponse(BaseTimestampResponse)` - Response DTO for chat messages
2253
- - `id: MessageId` - Unique message identifier
2254
- - `session_id: SessionId` - Session this message belongs to (aliased as "sessionId")
2255
- - `message: str` - Message content
2256
- - `sender_type: SenderType` - Type of sender (aliased as "senderType")
2257
- - `sender_name: str` - Name of sender (aliased as "senderName")
2258
- - `message_type: MessageType` - Type of message (aliased as "messageType")
2259
- - `created_time: int` - Creation timestamp in epoch ms (aliased as "createdTime")
2260
- - `updated_time: int | None` - Update timestamp in epoch ms (aliased as "updatedTime")
2261
-
2262
- - `SessionResponse(BaseTimestampResponse)` - Response DTO for chat sessions
2263
- - `id: SessionId` - Unique session identifier
2264
- - `user_id: UserId` - User who owns the session (aliased as "userId")
2265
- - `name: str | None` - Optional session name
2266
- - `agent_id: str | None` - Optional agent identifier (aliased as "agentId")
2267
- - `created_time: int` - Creation timestamp in epoch ms (aliased as "createdTime")
2268
- - `updated_time: int | None` - Update timestamp in epoch ms (aliased as "updatedTime")
2269
-
2270
- - `SessionListResponse(BaseModel)` - Response DTO for paginated session lists
2271
- - `sessions: list[SessionResponse]` - List of session objects
2272
- - `pagination: PaginationInfo | None` - Pagination metadata
2273
- - `total_count: int` - Total number of sessions (aliased as "totalCount")
2274
-
2275
- **Usage Examples:**
2276
- ```python
2277
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import (
2278
- MessageResponse,
2279
- SessionResponse,
2280
- SessionListResponse
2281
- )
2282
- from solace_agent_mesh.gateway.http_sse.shared.enums import MessageType, SenderType
2283
-
2284
- # Create a message response
2285
- message = MessageResponse(
2286
- id="msg_123",
2287
- session_id="sess_456",
2288
- message="Hello world",
2289
- sender_type=SenderType.USER,
2290
- sender_name="John Doe",
2291
- message_type=MessageType.TEXT,
2292
- created_time=1640995200000
2293
- )
2294
-
2295
- # Create a session response
2296
- session = SessionResponse(
2297
- id="sess_456",
2298
- user_id="user_789",
2299
- name="My Chat Session",
2300
- agent_id="agent_001",
2301
- created_time=1640995200000
2302
- )
2303
-
2304
- # Create a session list response
2305
- session_list = SessionListResponse(
2306
- sessions=[session],
2307
- total_count=1
2308
- )
2309
-
2310
- # Serialize to JSON (timestamps auto-converted to ISO strings)
2311
- json_output = message.model_dump_json()
2312
- ```
2313
-
2314
- ================================================================================
2315
-
2316
- ## Section 11: solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt
2317
-
2318
- **Source file:** `solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt`
2319
-
2320
- # DEVELOPER GUIDE for the routers directory
2321
-
2322
- ## Quick Summary
2323
- The `routers` directory contains FastAPI router modules that define the REST API endpoints for the HTTP SSE Gateway. Each router groups endpoints by functional domain (agent discovery, artifact management, authentication, sessions, etc.) and provides the primary interface for frontend applications and other clients to interact with the gateway. The routers work together to provide a complete web API with real-time capabilities through Server-Sent Events (SSE), along with comprehensive session management, artifact handling, and A2A message visualization.
2324
-
2325
- ## Files and Subdirectories Overview
2326
- - **Direct files:**
2327
- - `__init__.py` - Package initialization for router modules
2328
- - `agent_cards.py` - Agent discovery endpoints
2329
- - `artifacts.py` - Artifact management (upload, download, versioning)
2330
- - `auth.py` - Authentication flow endpoints (login, callback, refresh)
2331
- - `config.py` - Frontend configuration endpoint
2332
- - `feedback.py` - User feedback collection endpoints
2333
- - `people.py` - User search for autocomplete features
2334
- - `sessions.py` - Session management (CRUD operations)
2335
- - `sse.py` - Server-Sent Events streaming endpoint
2336
- - `tasks.py` - Task submission and management endpoints
2337
- - `users.py` - Current user information endpoint
2338
- - `visualization.py` - A2A message visualization streaming
2339
- - **Subdirectories:**
2340
- - `dto/` - Data Transfer Objects for request/response validation
2341
-
2342
- ## Developer API Reference
2343
-
2344
- ### Direct Files
2345
-
2346
- #### __init__.py
2347
- **Purpose:** Package initialization for the routers module
2348
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers import *`
2349
-
2350
- #### agent_cards.py
2351
- **Purpose:** Provides REST endpoints for agent discovery
2352
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.agent_cards import router`
2353
-
2354
- **Functions:**
2355
- - `get_discovered_agent_cards() -> List[AgentCard]` - Retrieves all currently discovered A2A agents
2356
-
2357
- #### artifacts.py
2358
- **Purpose:** Manages session-specific artifacts via REST endpoints with versioning and metadata support
2359
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.artifacts import router, ArtifactUploadResponse`
2360
-
2361
- **Classes:**
2362
- - `ArtifactUploadResponse(BaseModel)` - Response model for artifact uploads with camelCase fields
2363
-
2364
- **Functions:**
2365
- - `upload_artifact_with_session(upload_file: UploadFile, sessionId: str, filename: str, metadata_json: str) -> ArtifactUploadResponse` - Uploads artifact with session management
2366
- - `list_artifact_versions(session_id: str, filename: str) -> List[int]` - Lists available versions for an artifact
2367
- - `list_artifacts(session_id: str) -> List[ArtifactInfo]` - Lists all artifacts in a session with metadata
2368
- - `get_latest_artifact(session_id: str, filename: str) -> StreamingResponse` - Downloads latest artifact version with embed resolution
2369
- - `get_specific_artifact_version(session_id: str, filename: str, version: Union[int, str]) -> StreamingResponse` - Downloads specific version
2370
- - `get_artifact_by_uri(uri: str) -> StreamingResponse` - Downloads artifact by formal artifact:// URI
2371
- - `upload_artifact(session_id: str, filename: str, upload_file: UploadFile, metadata_json: Optional[str]) -> Dict[str, Any]` - Uploads new artifact version with metadata
2372
- - `delete_artifact(session_id: str, filename: str) -> Response` - Deletes artifact and all versions
2373
-
2374
- #### auth.py
2375
- **Purpose:** Handles OAuth-based user authentication flow with external authorization service
2376
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.auth import router`
2377
-
2378
- **Functions:**
2379
- - `initiate_login(request: FastAPIRequest) -> RedirectResponse` - Starts OAuth login flow with external service
2380
- - `get_csrf_token(response: Response) -> Dict[str, str]` - Generates and sets CSRF token
2381
- - `auth_callback(request: FastAPIRequest) -> RedirectResponse` - Handles OAuth callback and token exchange
2382
- - `refresh_token(request: FastAPIRequest) -> Dict[str, str]` - Refreshes access token using refresh token
2383
-
2384
- #### config.py
2385
- **Purpose:** Provides frontend configuration settings including feature flags
2386
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.config import router`
2387
-
2388
- **Functions:**
2389
- - `get_app_config() -> Dict[str, Any]` - Returns frontend configuration including auth URLs, feature flags, and persistence settings
2390
-
2391
- #### feedback.py
2392
- **Purpose:** Receives and processes user feedback on chat messages
2393
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.feedback import router, FeedbackPayload`
2394
-
2395
- **Classes:**
2396
- - `FeedbackPayload(BaseModel)` - Data model for feedback submission
2397
- - `task_id: str` - ID of the task being rated
2398
- - `session_id: str` - Session containing the task
2399
- - `feedback_type: Literal["up", "down"]` - Type of feedback
2400
- - `feedback_text: Optional[str]` - Optional text feedback
2401
-
2402
- **Functions:**
2403
- - `submit_feedback(payload: FeedbackPayload, user_id: str) -> Dict[str, str]` - Processes user feedback asynchronously
2404
-
2405
- #### people.py
2406
- **Purpose:** Provides user search functionality for autocomplete features
2407
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.people import router`
2408
-
2409
- **Functions:**
2410
- - `search_people(q: str, limit: int = 10) -> List[Dict[str, Any]]` - Searches for users for @mention autocomplete
2411
-
2412
- #### sessions.py
2413
- **Purpose:** Manages user sessions including CRUD operations with persistence
2414
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.sessions import router`
2415
-
2416
- **Functions:**
2417
- - `get_all_sessions(page_number: int, page_size: int, user: dict) -> PaginatedResponse[SessionResponse]` - Lists user's sessions with pagination
2418
- - `get_session(session_id: str, user: dict) -> DataResponse[SessionResponse]` - Gets session details with authorization
2419
- - `get_session_history(session_id: str, user: dict) -> List[MessageResponse]` - Gets session message history
2420
- - `update_session_name(session_id: str, name: str, user: dict) -> SessionResponse` - Updates session name with validation
2421
- - `delete_session(session_id: str, user: dict) -> None` - Deletes session with cascade notifications
2422
-
2423
- #### sse.py
2424
- **Purpose:** Provides Server-Sent Events endpoint for real-time streaming
2425
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.sse import router`
2426
-
2427
- **Functions:**
2428
- - `subscribe_to_task_events(task_id: str, request: FastAPIRequest) -> EventSourceResponse` - Establishes SSE connection for task updates with automatic cleanup
2429
-
2430
- #### tasks.py
2431
- **Purpose:** Handles task submission, management, and historical search
2432
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.tasks import router`
2433
-
2434
- **Functions:**
2435
- - `search_tasks(start_date: Optional[str], end_date: Optional[str], search: Optional[str], page: int, page_size: int, query_user_id: Optional[str]) -> List[Task]` - Searches historical tasks with admin capabilities
2436
- - `get_task_as_stim_file(task_id: str) -> Response` - Downloads complete task history as .stim file
2437
- - `send_task_to_agent(request: FastAPIRequest, payload: SendMessageRequest) -> SendMessageSuccessResponse` - Submits non-streaming task
2438
- - `subscribe_task_from_agent(request: FastAPIRequest, payload: SendStreamingMessageRequest) -> SendStreamingMessageSuccessResponse` - Submits streaming task
2439
- - `cancel_agent_task(request: FastAPIRequest, taskId: str, payload: CancelTaskRequest) -> Dict[str, str]` - Cancels active task
2440
-
2441
- #### users.py
2442
- **Purpose:** Provides current user information with authentication status
2443
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.users import router`
2444
-
2445
- **Functions:**
2446
- - `get_current_user_endpoint(user: dict) -> Dict[str, Any]` - Returns current user information with auth status
2447
-
2448
- #### visualization.py
2449
- **Purpose:** Manages A2A message visualization streams for real-time monitoring
2450
- **Import:** `from solace_agent_mesh.gateway.http_sse.routers.visualization import router, SubscriptionTarget, VisualizationSubscribeRequest`
2451
-
2452
- **Classes:**
2453
- - `SubscriptionTarget(BaseModel)` - Defines visualization target
2454
- - `type: str` - Target type (e.g., "current_namespace_a2a_messages", "agent_a2a_messages")
2455
- - `identifier: Optional[str]` - Target identifier (namespace or agent name)
2456
- - `VisualizationSubscribeRequest(BaseModel)` - Subscription request
2457
- - `subscription_targets: Optional[List[SubscriptionTarget]]` - Targets to monitor
2458
- - `client_stream_id: Optional[str]` - Client-generated stream ID for idempotency
2459
- - `VisualizationSubscribeResponse(BaseModel)` - Subscription response with SSE URL
2460
- - `VisualizationConfigUpdateRequest(BaseModel)` - Configuration update request
2461
- - `VisualizationConfigUpdateResponse(BaseModel)` - Configuration update response
2462
-
2463
- **Functions:**
2464
- - `subscribe_to_visualization_stream(request_data: VisualizationSubscribeRequest) -> VisualizationSubscribeResponse` - Starts visualization stream with authorization
2465
- - `get_visualization_stream_events(stream_id: str) -> EventSourceResponse` - SSE endpoint for visualization events
2466
- - `update_visualization_stream_config(stream_id: str, update_request: VisualizationConfigUpdateRequest) -> VisualizationConfigUpdateResponse` - Updates stream configuration
2467
- - `unsubscribe_from_visualization_stream(stream_id: str) -> Response` - Terminates visualization stream
2468
-
2469
- ### Subdirectory APIs
2470
-
2471
- #### dto/
2472
- **Purpose:** Provides Data Transfer Objects for request/response validation and serialization with automatic timestamp conversion
2473
- **Key Exports:** Request and response DTOs for session management with field validation and camelCase aliasing
2474
- **Import Examples:**
2475
- ```python
2476
- from solace_agent_mesh.gateway.http_sse.routers.dto.requests import GetSessionsRequest, UpdateSessionRequest
2477
- from solace_agent_mesh.gateway.http_sse.routers.dto.responses import SessionResponse, MessageResponse
2478
- ```
2479
-
2480
- ## Complete Usage Guide
2481
-
2482
- ### 1. Setting Up Routers in FastAPI Application
2483
-
2484
- ```python
2485
- from fastapi import FastAPI
2486
- from solace_agent_mesh.gateway.http_sse.routers import (
2487
- agent_cards,
2488
- artifacts,
2489
- auth,
2490
- config,
2491
- feedback,
2492
- people,
2493
- sessions,
2494
- sse,
2495
- tasks,
2496
- users,
2497
- visualization
2498
- )
2499
-
2500
- app = FastAPI()
2501
-
2502
- # Include all routers with appropriate prefixes
2503
- app.include_router(agent_cards.router, prefix="/api/v1", tags=["agents"])
2504
- app.include_router(artifacts.router, prefix="/api/v1/artifacts", tags=["artifacts"])
2505
- app.include_router(auth.router, prefix="/api/v1", tags=["auth"])
2506
- app.include_router(config.router, prefix="/api/v1", tags=["config"])
2507
- app.include_router(feedback.router, prefix="/api/v1", tags=["feedback"])
2508
- app.include_router(people.router, prefix="/api/v1", tags=["people"])
2509
- app.include_router(sessions.router, prefix="/api/v1", tags=["sessions"])
2510
- app.include_router(sse.router, prefix="/api/v1/sse", tags=["sse"])
2511
- app.include_router(tasks.router, prefix="/api/v1/tasks", tags=["tasks"])
2512
- app.include_router(users.router, prefix="/api/v1/users", tags=["users"])
2513
- app.include_router(visualization.router, prefix="/api/v1/visualization", tags=["visualization"])
2514
- ```
2515
-
2516
- ### 2. Agent Discovery and Task Submission
2517
-
2518
- ```python
2519
- import httpx
2520
- from a2a.types import SendStreamingMessageRequest, Message, MessagePart
2521
-
2522
- # Discover available agents
2523
- async def get_available_agents():
2524
- async with httpx.AsyncClient() as client:
2525
- response = await client.get("http://localhost:8000/api/v1/agentCards")
2526
- return response.json()
2527
-
2528
- # Submit a streaming task to an agent
2529
- async def submit_streaming_task(agent_name: str, message_text: str, session_id: str):
2530
- # Create message parts
2531
- parts = [MessagePart(text=message_text)]
2532
-
2533
- # Create message with metadata
2534
- message = Message(
2535
- parts=parts,
2536
- context_id=session_id,
2537
- metadata={"agent_name": agent_name}
2538
- )
2539
-
2540
- # Create request payload
2541
- payload = SendStreamingMessageRequest(
2542
- method="message:stream",
2543
- params={"message": message},
2544
- id="req_123"
2545
- )
2546
-
2547
- async with httpx.AsyncClient() as client:
2548
- response = await client.post(
2549
- "http://localhost:8000/api/v1/tasks/message:stream",
2550
- json=payload.model_dump()
2551
- )
2552
- return response.json()
2553
-
2554
- # Search historical tasks (admin users can query all users)
2555
- async def search_historical_tasks(start_date: str = None, query_user_id: str = None):
2556
- params = {}
2557
- if start_date:
2558
- params["start_date"] = start_date
2559
- if query_user_id:
2560
- params["query_user_id"] = query_user_id
2561
-
2562
- async with httpx.AsyncClient() as client:
2563
- response = await client.get(
2564
- "http://localhost:8000/api/v1/tasks",
2565
- params=params
2566
- )
2567
- return response.json()
2568
- ```
2569
-
2570
- ### 3. Real-time Event Streaming with SSE
2571
-
2572
- ```python
2573
- import asyncio
2574
- import httpx
2575
- import json
2576
-
2577
- # Client-side SSE connection for task events
2578
- async def listen_to_task_events(task_id: str):
2579
- async with httpx.AsyncClient() as client:
2580
- async with client.stream(
2581
- "GET",
2582
- f"http://localhost:8000/api/v1/sse/subscribe/{task_id}",
2583
- headers={"Accept": "text/event-stream"}
2584
- ) as response:
2585
- async for line in response.aiter_lines():
2586
- if line.startswith("data: "):
2587
- event_data = line[6:] # Remove "data: " prefix
2588
- try:
2589
- parsed_data = json.loads(event_data)
2590
- print(f"Received event: {parsed_data}")
2591
- except json.JSONDecodeError:
2592
- print(f"Received raw data: {event_data}")
2593
-
2594
- # Client-side SSE connection for visualization
2595
- async def listen_to_visualization_events(stream_id: str):
2596
- async with httpx.AsyncClient() as client:
2597
- async with client.stream(
2598
- "GET",
2599
- f"http://localhost:8000/api/v1/visualization/{stream_id}/events",
2600
- headers={"Accept": "text/event-stream"}
2601
- ) as response:
2602
- async for line in response.aiter_lines():
2603
- if line.startswith("data: "):
2604
- event_data = line[6:]
2605
- print(f"Visualization event: {event_data}")
2606
- ```
2607
-
2608
- ### 4. Comprehensive Artifact Management
2609
-
2610
- ```python
2611
- import httpx
2612
- import json
2613
- from pathlib import Path
2614
-
2615
- # Upload an artifact with metadata using session-based endpoint
2616
- async def upload_artifact_with_metadata(session_id: str, filename: str, file_path: Path, metadata: dict = None):
2617
- files = {"upload_file": (filename, file_path.open("rb"))}
2618
- data = {}
2619
-
2620
- if metadata:
2621
- data["metadata_json"] = json.dumps(metadata)
2622
-
2623
- async with httpx.AsyncClient() as client:
2624
- response = await client.post(
2625
- f"http://localhost:8000/api/v1/artifacts/{session_id}/{filename}",
2626
- files=files,
2627
- data=data
2628
- )
2629
- return response.json()
2630
-
2631
- # Upload artifact with automatic session creation
2632
-
2633
- ================================================================================
2634
-
2635
- ## Section 12: solace_agent_mesh/gateway/http_sse/services/services_llm.txt
2636
-
2637
- **Source file:** `solace_agent_mesh/gateway/http_sse/services/services_llm.txt`
2638
-
2639
- # DEVELOPER GUIDE: services
2640
-
2641
- ## Quick Summary
2642
- The `services` directory contains the business logic layer for the HTTP SSE Gateway. It provides high-level services for agent management (discovering and retrieving A2A agents), user feedback processing with database persistence and event publishing, user search via identity services, session management with database persistence, task logging to database, data retention/cleanup, and A2A task operations like cancellation.
2643
-
2644
- ## Files Overview
2645
- - `__init__.py` - Package initialization file marking the directory as a Python package
2646
- - `agent_card_service.py` - Service for retrieving information about discovered A2A agents from the registry
2647
- - `data_retention_service.py` - Service for automatic cleanup of old tasks and feedback based on retention policies
2648
- - `feedback_service.py` - Service for processing and storing user feedback on chat messages with database and event publishing
2649
- - `people_service.py` - Service for searching users via configured identity services
2650
- - `session_service.py` - Service for managing chat sessions and messages with database persistence
2651
- - `task_logger_service.py` - Service for logging A2A tasks and events to the database
2652
- - `task_service.py` - Service for handling A2A task operations like cancellation
2653
-
2654
- ## Developer API Reference
2655
-
2656
- ### __init__.py
2657
- **Purpose:** Marks the services directory as a Python package
2658
- **Import:** N/A - No public interfaces
2659
-
2660
- ### agent_card_service.py
2661
- **Purpose:** Provides methods for accessing information about discovered A2A agents from the shared AgentRegistry
2662
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.agent_card_service import AgentCardService`
2663
-
2664
- **Classes:**
2665
- - `AgentCardService(agent_registry: AgentRegistry)` - Service for accessing discovered A2A agent information
2666
- - `get_all_agent_cards() -> List[AgentCard]` - Retrieves all currently discovered and registered agent cards
2667
- - `get_agent_card_by_name(agent_name: str) -> Optional[AgentCard]` - Retrieves a specific agent card by name, returns None if not found
2668
-
2669
- **Usage Examples:**
2670
- ```python
2671
- from solace_agent_mesh.gateway.http_sse.services.agent_card_service import AgentCardService
2672
- from solace_agent_mesh.common.agent_registry import AgentRegistry
2673
-
2674
- # Initialize with shared agent registry
2675
- agent_registry = AgentRegistry() # Usually injected as shared instance
2676
- agent_service = AgentCardService(agent_registry=agent_registry)
2677
-
2678
- # Get all available agents
2679
- all_agents = agent_service.get_all_agent_cards()
2680
- print(f"Found {len(all_agents)} agents")
2681
-
2682
- # Get specific agent by name
2683
- agent = agent_service.get_agent_card_by_name("data-processor")
2684
- if agent:
2685
- print(f"Found agent: {agent.name}")
2686
- else:
2687
- print("Agent not found")
2688
- ```
2689
-
2690
- ### data_retention_service.py
2691
- **Purpose:** Service for automatically cleaning up old tasks, task events, and feedback based on configurable retention policies
2692
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.data_retention_service import DataRetentionService`
2693
-
2694
- **Classes:**
2695
- - `DataRetentionService(session_factory: Callable[[], DBSession] | None, config: Dict[str, Any])` - Service for automatic data cleanup based on retention policies
2696
- - `cleanup_old_data() -> None` - Main orchestration method for cleaning up old data, calls cleanup methods for tasks and feedback
2697
-
2698
- **Constants/Variables:**
2699
- - `MIN_RETENTION_DAYS: int` - Minimum retention period (7 days)
2700
- - `MIN_CLEANUP_INTERVAL_HOURS: int` - Minimum cleanup interval (1 hour)
2701
- - `MIN_BATCH_SIZE: int` - Minimum batch size for deletion (1)
2702
- - `MAX_BATCH_SIZE: int` - Maximum batch size for deletion (10000)
2703
-
2704
- **Usage Examples:**
2705
- ```python
2706
- from solace_agent_mesh.gateway.http_sse.services.data_retention_service import DataRetentionService
2707
- from sqlalchemy.orm import sessionmaker
2708
-
2709
- # Initialize with database session factory and config
2710
- session_factory = sessionmaker(bind=your_engine)
2711
- config = {
2712
- "enabled": True,
2713
- "task_retention_days": 90,
2714
- "feedback_retention_days": 90,
2715
- "cleanup_interval_hours": 24,
2716
- "batch_size": 1000
2717
- }
2718
-
2719
- retention_service = DataRetentionService(
2720
- session_factory=session_factory,
2721
- config=config
2722
- )
2723
-
2724
- # Run cleanup (typically called by scheduler)
2725
- retention_service.cleanup_old_data()
2726
- ```
2727
-
2728
- ### feedback_service.py
2729
- **Purpose:** Handles the business logic for processing and storing user feedback with database persistence and event publishing
2730
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.feedback_service import FeedbackService`
2731
-
2732
- **Classes:**
2733
- - `FeedbackService(session_factory: Callable[[], DBSession] | None, component: WebUIBackendComponent, task_repo: ITaskRepository)` - Service for processing user feedback with database persistence and event publishing
2734
- - `process_feedback(payload: FeedbackPayload, user_id: str) -> None` - Asynchronously processes and stores feedback, publishes events if configured
2735
-
2736
- **Usage Examples:**
2737
- ```python
2738
- import asyncio
2739
- from solace_agent_mesh.gateway.http_sse.services.feedback_service import FeedbackService
2740
- from sqlalchemy.orm import sessionmaker
2741
-
2742
- # Initialize with database session factory
2743
- session_factory = sessionmaker(bind=your_engine)
2744
- component = YourWebUIBackendComponent() # Your component instance
2745
- task_repo = YourTaskRepository() # Your task repository
2746
-
2747
- feedback_service = FeedbackService(
2748
- session_factory=session_factory,
2749
- component=component,
2750
- task_repo=task_repo
2751
- )
2752
-
2753
- # Process feedback (requires FeedbackPayload from router)
2754
- async def process_user_feedback():
2755
- # payload would be a FeedbackPayload instance from the router
2756
- await feedback_service.process_feedback(payload, user_id="user123")
2757
-
2758
- asyncio.run(process_user_feedback())
2759
- ```
2760
-
2761
- ### people_service.py
2762
- **Purpose:** Provides user search functionality via configured identity services
2763
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.people_service import PeopleService`
2764
-
2765
- **Classes:**
2766
- - `PeopleService(identity_service: Optional[BaseIdentityService])` - Service for searching and retrieving user information
2767
- - `search_for_users(query: str, limit: int = 10) -> List[Dict[str, Any]]` - Asynchronously searches for users, returns empty list if no identity service configured or query too short
2768
-
2769
- **Usage Examples:**
2770
- ```python
2771
- import asyncio
2772
- from solace_agent_mesh.gateway.http_sse.services.people_service import PeopleService
2773
- from solace_agent_mesh.common.services.identity_service import BaseIdentityService
2774
-
2775
- # Initialize with identity service
2776
- identity_service = SomeIdentityService() # Your identity service implementation
2777
- people_service = PeopleService(identity_service=identity_service)
2778
-
2779
- async def search_users():
2780
- # Search for users
2781
- users = await people_service.search_for_users("john", limit=5)
2782
- for user in users:
2783
- print(f"User: {user.get('name')} - {user.get('email')}")
2784
-
2785
- # Initialize without identity service (graceful degradation)
2786
- people_service_no_id = PeopleService(identity_service=None)
2787
- # search_for_users will return empty list
2788
-
2789
- asyncio.run(search_users())
2790
- ```
2791
-
2792
- ### session_service.py
2793
- **Purpose:** Manages chat sessions and messages with database persistence support
2794
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.session_service import SessionService`
2795
-
2796
- **Classes:**
2797
- - `SessionService(component: WebUIBackendComponent = None)` - Service for managing chat sessions and messages
2798
- - `is_persistence_enabled() -> bool` - Checks if the service is configured with a persistent backend
2799
- - `get_user_sessions(db: DbSession, user_id: UserId, pagination: PaginationParams | None = None) -> PaginatedResponse[Session]` - Retrieves paginated sessions for a user
2800
- - `get_session_details(db: DbSession, session_id: SessionId, user_id: UserId) -> Session | None` - Gets session details for a specific session
2801
- - `get_session_history(db: DbSession, session_id: SessionId, user_id: UserId, pagination: PaginationInfo | None = None) -> SessionHistory | None` - Gets session with messages
2802
- - `create_session(db: DbSession, user_id: UserId, name: str | None = None, agent_id: str | None = None, session_id: str | None = None) -> Optional[Session]` - Creates a new session
2803
- - `update_session_name(db: DbSession, session_id: SessionId, user_id: UserId, name: str) -> Session | None` - Updates session name
2804
- - `delete_session_with_notifications(db: DbSession, session_id: SessionId, user_id: UserId) -> bool` - Deletes session and notifies agents
2805
- - `add_message_to_session(db: DbSession, session_id: SessionId, user_id: UserId, message: str, sender_type: SenderType, sender_name: str, agent_id: str | None = None, message_type: MessageType = MessageType.TEXT) -> Message` - Adds a message to a session
2806
-
2807
- **Usage Examples:**
2808
- ```python
2809
- from solace_agent_mesh.gateway.http_sse.services.session_service import SessionService
2810
- from solace_agent_mesh.gateway.http_sse.shared.enums import SenderType, MessageType
2811
- from sqlalchemy.orm import Session as DbSession
2812
-
2813
- # Initialize with component
2814
- component = YourWebUIBackendComponent() # Your component
2815
- session_service = SessionService(component=component)
2816
-
2817
- # Use with database session
2818
- with your_session_factory() as db:
2819
- # Create a new session
2820
- session = session_service.create_session(
2821
- db=db,
2822
- user_id="user123",
2823
- name="My Chat Session",
2824
- agent_id="assistant-agent"
2825
- )
2826
-
2827
- # Add a message to the session
2828
- message = session_service.add_message_to_session(
2829
- db=db,
2830
- session_id=session.id,
2831
- user_id="user123",
2832
- message="Hello, how can you help me?",
2833
- sender_type=SenderType.USER,
2834
- sender_name="John Doe"
2835
- )
2836
-
2837
- # Get user's sessions with pagination
2838
- paginated_sessions = session_service.get_user_sessions(db, "user123")
2839
-
2840
- db.commit()
2841
- ```
2842
-
2843
- ### task_logger_service.py
2844
- **Purpose:** Service for logging A2A tasks and events to the database with configurable filtering and sanitization
2845
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.task_logger_service import TaskLoggerService`
2846
-
2847
- **Classes:**
2848
- - `TaskLoggerService(session_factory: Callable[[], DBSession] | None, config: Dict[str, Any])` - Service for logging A2A tasks and events to database
2849
- - `log_event(event_data: Dict[str, Any]) -> None` - Parses a raw A2A message and logs it as a task event, creates or updates master task record
2850
-
2851
- **Usage Examples:**
2852
- ```python
2853
- from solace_agent_mesh.gateway.http_sse.services.task_logger_service import TaskLoggerService
2854
- from sqlalchemy.orm import sessionmaker
2855
-
2856
- # Initialize with database session factory and config
2857
- session_factory = sessionmaker(bind=your_engine)
2858
- config = {
2859
- "enabled": True,
2860
- "log_status_updates": True,
2861
- "log_artifact_events": False,
2862
- "log_file_parts": True,
2863
- "max_file_part_size_bytes": 102400
2864
- }
2865
-
2866
- task_logger = TaskLoggerService(
2867
- session_factory=session_factory,
2868
- config=config
2869
- )
2870
-
2871
- # Log an A2A event
2872
- event_data = {
2873
- "topic": "sam/agents/my-agent/request",
2874
- "payload": {"id": "task-123", "method": "sendMessage"},
2875
- "user_properties": {"userId": "user@example.com"}
2876
- }
2877
-
2878
- task_logger.log_event(event_data)
2879
- ```
2880
-
2881
- ### task_service.py
2882
- **Purpose:** Handles A2A task operations, specifically task cancellation using CoreA2AService and message publishing
2883
- **Import:** `from solace_agent_mesh.gateway.http_sse.services.task_service import TaskService, PublishFunc`
2884
-
2885
- **Type Aliases:**
2886
- - `PublishFunc: Callable[[str, Dict, Optional[Dict]], None]` - Function type for publishing messages (topic, payload, user_properties)
2887
-
2888
- **Classes:**
2889
- - `TaskService(core_a2a_service: CoreA2AService, publish_func: PublishFunc, namespace: str, gateway_id: str, sse_manager: SSEManager, task_context_map: Dict[str, Dict], task_context_lock: threading.Lock, app_name: str)` - Service for managing A2A task operations
2890
- - `cancel_task(agent_name: str, task_id: str, client_id: str, user_id: str = "web_user") -> None` - Asynchronously cancels a task by publishing A2A CancelTaskRequest message
2891
-
2892
- **Usage Examples:**
2893
- ```python
2894
- import asyncio
2895
- import threading
2896
- from solace_agent_mesh.gateway.http_sse.services.task_service import TaskService, PublishFunc
2897
- from solace_agent_mesh.core_a2a.service import CoreA2AService
2898
- from solace_agent_mesh.gateway.http_sse.sse_manager import SSEManager
2899
-
2900
- # Define publish function
2901
- def my_publish_func(topic: str, payload: dict, user_properties: dict = None):
2902
- print(f"Publishing to {topic}: {payload}")
2903
- # Your actual message publishing logic here
2904
-
2905
- # Initialize dependencies
2906
- core_a2a_service = CoreA2AService() # Your core A2A service
2907
- sse_manager = SSEManager()
2908
- task_context_map = {}
2909
- task_context_lock = threading.Lock()
2910
-
2911
- # Create task service
2912
- task_service = TaskService(
2913
- core_a2a_service=core_a2a_service,
2914
- publish_func=my_publish_func,
2915
- namespace="my-namespace",
2916
- gateway_id="gateway-01",
2917
- sse_manager=sse_manager,
2918
- task_context_map=task_context_map,
2919
- task_context_lock=task_context_lock,
2920
- app_name="my-app"
2921
- )
2922
-
2923
- async def cancel_task_example():
2924
- # Cancel a task
2925
- await task_service.cancel_task(
2926
- agent_name="data-processor",
2927
- task_id="task-123",
2928
- client_id="client-456",
2929
- user_id="user@example.com"
2930
- )
2931
-
2932
- asyncio.run(cancel_task_example())
2933
- ```
2934
-
2935
- ================================================================================
2936
-
2937
- ## Section 13: solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt
2938
-
2939
- **Source file:** `solace_agent_mesh/gateway/http_sse/shared/shared_llm.txt`
2940
-
2941
- # DEVELOPER GUIDE: shared
2942
-
2943
- ## Quick Summary
2944
- The `shared` directory contains common utilities, constants, enums, types, and exception handling used across all layers of the HTTP SSE gateway. It provides authentication helpers, timestamp utilities, standardized exception handling, database utilities, pagination support, and response formatting for consistent API behavior.
2945
-
2946
- ## Files Overview
2947
- - `__init__.py` - Central exports for all shared utilities and components
2948
- - `auth_utils.py` - Authentication utilities for FastAPI applications
2949
- - `timestamp_utils.py` - Epoch timestamp utilities matching Java backend patterns
2950
- - `exceptions.py` - Generic web exceptions for HTTP/REST APIs
2951
- - `error_dto.py` - Standardized error response DTOs
2952
- - `exception_handlers.py` - FastAPI exception handlers for consistent HTTP error responses
2953
- - `base_repository.py` - Base repository classes with proper transaction management
2954
- - `pagination.py` - Pagination utilities for API responses
2955
- - `database_exceptions.py` - Database exception handling and conversion
2956
- - `database_helpers.py` - Database utility functions and custom types
2957
- - `response_utils.py` - Standardized response formatting utilities
2958
- - `enums.py` - Enumerations for message types, task status, and validation errors
2959
- - `types.py` - Custom types and type aliases for better type safety
2960
- - `utils.py` - Generic utility functions
2961
-
2962
- ## Developer API Reference
2963
-
2964
- ### auth_utils.py
2965
- **Purpose:** Provides authentication utilities for FastAPI controllers
2966
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import get_current_user`
2967
-
2968
- **Functions:**
2969
- - `get_current_user(request: FastAPIRequest) -> dict` - Extracts authenticated user from request state, returns user info or anonymous default
2970
-
2971
- **Usage Examples:**
2972
- ```python
2973
- from fastapi import Depends
2974
- from solace_agent_mesh.gateway.http_sse.shared import get_current_user
2975
-
2976
- @app.get("/protected")
2977
- async def protected_endpoint(user: dict = Depends(get_current_user)):
2978
- return {"user_id": user["id"], "name": user["name"]}
2979
- ```
2980
-
2981
- ### timestamp_utils.py
2982
- **Purpose:** Provides epoch timestamp utilities for database portability and timezone handling
2983
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import now_epoch_ms, epoch_ms_to_iso8601, iso8601_to_epoch_ms`
2984
-
2985
- **Functions:**
2986
- - `now_epoch_ms() -> int` - Get current time as milliseconds since epoch
2987
- - `epoch_ms_to_iso8601(epoch_ms: int) -> str` - Convert epoch milliseconds to ISO 8601 string
2988
- - `iso8601_to_epoch_ms(iso8601_string: str) -> int` - Convert ISO 8601 string to epoch milliseconds
2989
- - `datetime_to_epoch_ms(dt: datetime) -> int` - Convert datetime object to epoch milliseconds
2990
- - `epoch_ms_to_datetime(epoch_ms: int) -> datetime` - Convert epoch milliseconds to datetime object
2991
- - `validate_epoch_ms(epoch_ms: int | None) -> bool` - Validate that an epoch milliseconds value is reasonable
2992
-
2993
- **Usage Examples:**
2994
- ```python
2995
- from solace_agent_mesh.gateway.http_sse.shared import (
2996
- now_epoch_ms, epoch_ms_to_iso8601, iso8601_to_epoch_ms
2997
- )
2998
-
2999
- # Get current timestamp for database storage
3000
- created_time = now_epoch_ms()
3001
-
3002
- # Convert for API response
3003
- iso_string = epoch_ms_to_iso8601(created_time)
3004
-
3005
- # Parse from API request
3006
- timestamp = iso8601_to_epoch_ms("2024-01-01T00:00:00Z")
3007
- ```
3008
-
3009
- ### exceptions.py
3010
- **Purpose:** Generic web exceptions for HTTP/REST APIs
3011
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import ValidationError, EntityNotFoundError, EntityAlreadyExistsError`
3012
-
3013
- **Classes:**
3014
- - `WebUIBackendException(message: str, details: Optional[Dict[str, Any]] = None)` - Base exception for all web UI backend errors
3015
- - `ValidationError(message: str, validation_details: Optional[Dict[str, List[str]]] = None, entity_type: Optional[str] = None, entity_identifier: Optional[str] = None)` - Exception for validation errors with field-level details
3016
- - `EntityNotFoundError(entity_type: str, entity_id: str)` - Generic exception for when an entity is not found
3017
- - `EntityAlreadyExistsError(entity_type: str, identifier: str, value: Any = None)` - Exception for when an entity already exists
3018
- - `BusinessRuleViolationError(rule: str, message: str)` - Exception for business rule violations
3019
- - `ConfigurationError(component: str, message: str)` - Exception for configuration-related errors
3020
- - `DataIntegrityError(constraint: str, message: str)` - Exception for data integrity violations
3021
- - `ExternalServiceError(service: str, message: str, status_code: Optional[int] = None)` - Exception for external service communication errors
3022
- - `ValidationErrorBuilder()` - Builder for constructing ValidationError instances with fluent API
3023
-
3024
- **Usage Examples:**
3025
- ```python
3026
- from solace_agent_mesh.gateway.http_sse.shared import (
3027
- ValidationError, EntityNotFoundError, ValidationErrorBuilder
3028
- )
3029
-
3030
- # Simple validation error
3031
- raise ValidationError("Invalid input data")
3032
-
3033
- # Entity not found
3034
- raise EntityNotFoundError("User", "123")
3035
-
3036
- # Complex validation with builder
3037
- error = ValidationError.builder() \
3038
- .message("Invalid user data") \
3039
- .validation_detail("email", ["Invalid email format"]) \
3040
- .entity_type("User") \
3041
- .build()
3042
- ```
3043
-
3044
- ### error_dto.py
3045
- **Purpose:** Standardized error response DTOs for HTTP APIs
3046
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import EventErrorDTO`
3047
-
3048
- **Classes:**
3049
- - `EventErrorDTO(message: str, validationDetails: Optional[Dict[str, List[str]]] = None)` - Simplified and standardized error response format
3050
- - `create(message: str, validation_details: Optional[Dict[str, List[str]]] = None) -> EventErrorDTO` - Create a new EventErrorDTO
3051
- - `not_found(entity_type: str, entity_id: str) -> EventErrorDTO` - Create a 404 Not Found error
3052
- - `validation_error(message: str, validation_details: Dict[str, List[str]]) -> EventErrorDTO` - Create a validation error
3053
-
3054
- **Usage Examples:**
3055
- ```python
3056
- from solace_agent_mesh.gateway.http_sse.shared import EventErrorDTO
3057
-
3058
- # Simple error
3059
- error = EventErrorDTO.create("Something went wrong")
3060
-
3061
- # Not found error
3062
- error = EventErrorDTO.not_found("User", "123")
3063
-
3064
- # Validation error
3065
- error = EventErrorDTO.validation_error(
3066
- "Invalid data",
3067
- {"email": ["Invalid format"], "age": ["Must be positive"]}
3068
- )
3069
- ```
3070
-
3071
- ### exception_handlers.py
3072
- **Purpose:** FastAPI exception handlers for consistent HTTP error responses
3073
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import register_exception_handlers`
3074
-
3075
- **Functions:**
3076
- - `register_exception_handlers(app)` - Register all exception handlers with a FastAPI app
3077
- - `create_error_response(status_code: int, message: str, validation_details: dict = None) -> JSONResponse` - Create standardized error response
3078
-
3079
- **Usage Examples:**
3080
- ```python
3081
- from fastapi import FastAPI
3082
- from solace_agent_mesh.gateway.http_sse.shared import register_exception_handlers
3083
-
3084
- app = FastAPI()
3085
- register_exception_handlers(app)
3086
- ```
3087
-
3088
- ### base_repository.py
3089
- **Purpose:** Base repository classes with proper transaction management
3090
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import BaseRepository, PaginatedRepository, ValidationMixin`
3091
-
3092
- **Classes:**
3093
- - `BaseRepository(model_class: Type[ModelType], entity_class: Type[EntityType])` - Abstract base class for repositories
3094
- - `create(session: Session, create_data: Dict[str, Any]) -> EntityType` - Create a new entity
3095
- - `get_by_id(session: Session, entity_id: Any) -> EntityType` - Get entity by ID
3096
- - `get_all(session: Session, limit: Optional[int] = None, offset: Optional[int] = None) -> List[EntityType]` - Get all entities
3097
- - `update(session: Session, entity_id: Any, update_data: Dict[str, Any]) -> EntityType` - Update an entity
3098
- - `delete(session: Session, entity_id: Any) -> None` - Delete an entity
3099
- - `PaginatedRepository(model_class: Type[ModelType], entity_class: Type[EntityType])` - Base repository with enhanced pagination support
3100
- - `get_paginated(session: Session, page_number: int, page_size: int) -> tuple[List[EntityType], int]` - Get paginated results
3101
- - `ValidationMixin` - Mixin for repositories that need validation logic
3102
-
3103
- **Usage Examples:**
3104
- ```python
3105
- from solace_agent_mesh.gateway.http_sse.shared import BaseRepository
3106
- from sqlalchemy.orm import Session
3107
-
3108
- class UserRepository(BaseRepository[UserModel, UserEntity]):
3109
- @property
3110
- def entity_name(self) -> str:
3111
- return "User"
3112
-
3113
- # Usage
3114
- repo = UserRepository(UserModel, UserEntity)
3115
- user = repo.create(session, {"name": "John", "email": "john@example.com"})
3116
- ```
3117
-
3118
- ### pagination.py
3119
- **Purpose:** Pagination utilities for API responses
3120
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import PaginationParams, PaginatedResponse, DataResponse`
3121
-
3122
- **Classes:**
3123
- - `PaginationParams(page_number: int = 1, page_size: int = 20)` - Request parameters for pagination
3124
- - `offset: int` - Calculate the offset for database queries
3125
- - `PaginatedResponse[T](data: list[T], meta: Meta)` - Generic paginated response with data and metadata
3126
- - `create(data: list[T], total_count: int, pagination: PaginationParams) -> PaginatedResponse[T]` - Create paginated response
3127
- - `DataResponse[T](data: T)` - Simple data response wrapper
3128
- - `create(data: T) -> DataResponse[T]` - Create data response
3129
-
3130
- **Usage Examples:**
3131
- ```python
3132
- from solace_agent_mesh.gateway.http_sse.shared import PaginationParams, PaginatedResponse
3133
-
3134
- # Create pagination params
3135
- pagination = PaginationParams(page_number=1, page_size=20)
3136
-
3137
- # Create paginated response
3138
- response = PaginatedResponse.create(users, total_count=100, pagination=pagination)
3139
- ```
3140
-
3141
- ### response_utils.py
3142
- **Purpose:** Standardized response formatting utilities
3143
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import create_data_response, create_paginated_response, StandardResponseMixin`
3144
-
3145
- **Functions:**
3146
- - `create_data_response(data: T) -> DataResponse[T]` - Create a standardized data response
3147
- - `create_paginated_response(data: List[T], total_count: int, pagination_params: PaginationParams) -> PaginatedResponse[T]` - Create a standardized paginated response
3148
- - `create_success_response(message: str = "Success") -> DataResponse[Dict[str, str]]` - Create a standardized success response
3149
- - `create_list_response(items: List[T]) -> DataResponse[List[T]]` - Create a standardized list response
3150
-
3151
- **Classes:**
3152
- - `StandardResponseMixin` - Mixin class to add standard response methods to services or controllers
3153
-
3154
- **Usage Examples:**
3155
- ```python
3156
- from solace_agent_mesh.gateway.http_sse.shared import create_data_response, create_paginated_response
3157
-
3158
- # Simple data response
3159
- response = create_data_response({"id": 1, "name": "test"})
3160
-
3161
- # Paginated response
3162
- response = create_paginated_response(users, 100, pagination_params)
3163
- ```
3164
-
3165
- ### database_exceptions.py
3166
- **Purpose:** Database exception handling and conversion
3167
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import DatabaseExceptionHandler, handle_database_errors`
3168
-
3169
- **Classes:**
3170
- - `DatabaseExceptionHandler` - Centralized handler for converting SQLAlchemy exceptions to domain exceptions
3171
- - `handle_integrity_error(e: IntegrityError, entity_type: str = "Resource") -> ValidationError` - Convert integrity constraint violations
3172
- - `handle_operational_error(e: OperationalError, entity_type: str = "Resource") -> DataIntegrityError` - Handle operational errors
3173
-
3174
- **Functions:**
3175
- - `handle_database_errors(entity_type: str = "Resource")` - Convenience decorator for database exception handling
3176
-
3177
- **Usage Examples:**
3178
- ```python
3179
- from solace_agent_mesh.gateway.http_sse.shared import handle_database_errors
3180
-
3181
- class UserRepository:
3182
- @handle_database_errors("User")
3183
- def create_user(self, session, data):
3184
- # Repository method implementation
3185
- pass
3186
- ```
3187
-
3188
- ### database_helpers.py
3189
- **Purpose:** Database utility functions and custom types
3190
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import SimpleJSON`
3191
-
3192
- **Classes:**
3193
- - `SimpleJSON(TypeDecorator)` - Simple JSON type using Text storage for all databases
3194
-
3195
- **Usage Examples:**
3196
- ```python
3197
- from sqlalchemy import Column, String
3198
- from solace_agent_mesh.gateway.http_sse.shared import SimpleJSON
3199
-
3200
- class MyModel(Base):
3201
- id = Column(String, primary_key=True)
3202
- metadata = Column(SimpleJSON) # Stores JSON as text
3203
- ```
3204
-
3205
- ### utils.py
3206
- **Purpose:** Generic utility functions
3207
- **Import:** `from solace_agent_mesh.gateway.http_sse.shared import generate_uuid, to_snake_case, to_pascal_case`
3208
-
3209
- **Functions:**
3210
- - `generate_uuid() -> str` - Generate a UUID string for database storage
3211
- - `to_snake_case(name: str) -> str` - Convert a string to snake_case
3212
- - `to_pascal_case(name: str) -> str` - Convert a string to PascalCase
3213
-
3214
- **Usage Examples:**
3215
- ```python
3216
- from solace_agent_mesh.gateway.http_sse.shared import generate_uuid, to_snake_case
3217
-
3218
- # Generate unique ID
3219
- user_id = generate_uuid()
3220
-
3221
- # Convert naming
3222
- snake_name = to_snake_case("User Name") # "user_name"
3223
- ```
3224
-
3225
- ================================================================================
3226
-
3227
- ## Section 14: solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt
3228
-
3229
- **Source file:** `solace_agent_mesh/gateway/http_sse/utils/utils_llm.txt`
3230
-
3231
- ## Quick Summary
3232
- The `utils` directory provides utility functions for the HTTP SSE Gateway, specifically for creating .stim file structures from task and event data.
3233
-
3234
- ## Files Overview
3235
- - `__init__.py` - Package initialization file for HTTP SSE Gateway utilities
3236
- - `stim_utils.py` - Utility functions for formatting task data into .stim file structures
3237
-
3238
- ## Developer API Reference
3239
-
3240
- ### __init__.py
3241
- **Purpose:** Package initialization for HTTP SSE Gateway utilities
3242
- **Import:** `from solace_agent_mesh.gateway.http_sse.utils import *`
3243
-
3244
- This file serves as the package entry point and contains no public interfaces.
3245
-
3246
- ### stim_utils.py
3247
- **Purpose:** Provides utility functions for creating .stim file structures from task and event data
3248
- **Import:** `from solace_agent_mesh.gateway.http_sse.utils.stim_utils import create_stim_from_task_data`
3249
-
3250
- **Functions:**
3251
- - `create_stim_from_task_data(task: Task, events: List[TaskEvent]) -> dict` - Formats a task and its events into the .stim file structure with version 2.0 format for gateway-generated logs
3252
-
3253
- **Usage Examples:**
3254
- ```python
3255
- from solace_agent_mesh.gateway.http_sse.utils.stim_utils import create_stim_from_task_data
3256
- from solace_agent_mesh.gateway.http_sse.repository.entities import Task, TaskEvent
3257
-
3258
- # Create a .stim file structure from task and events
3259
- task = Task(
3260
- id="task_123",
3261
- user_id="user_456",
3262
- start_time="2024-01-01T10:00:00Z",
3263
- end_time="2024-01-01T10:05:00Z",
3264
- status="completed",
3265
- initial_request_text="Process this data"
3266
- )
3267
-
3268
- events = [
3269
- TaskEvent(event_type="start", timestamp="2024-01-01T10:00:00Z"),
3270
- TaskEvent(event_type="complete", timestamp="2024-01-01T10:05:00Z")
3271
- ]
3272
-
3273
- stim_data = create_stim_from_task_data(task, events)
3274
- # Returns a dictionary with 'invocation_details' and 'invocation_flow' keys
3275
- ```
3276
-
3277
- ================================================================================
3278
-