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