solace-agent-mesh 0.2.3__py3-none-any.whl → 1.0.1__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/adk_llm.txt +93 -0
- solace_agent_mesh/agent/adk/app_llm_agent.py +26 -0
- solace_agent_mesh/agent/adk/callbacks.py +1694 -0
- solace_agent_mesh/agent/adk/filesystem_artifact_service.py +381 -0
- solace_agent_mesh/agent/adk/invocation_monitor.py +295 -0
- solace_agent_mesh/agent/adk/models/lite_llm.py +872 -0
- solace_agent_mesh/agent/adk/models/models_llm.txt +94 -0
- solace_agent_mesh/agent/adk/runner.py +353 -0
- solace_agent_mesh/agent/adk/services.py +240 -0
- solace_agent_mesh/agent/adk/setup.py +751 -0
- solace_agent_mesh/agent/adk/stream_parser.py +214 -0
- solace_agent_mesh/agent/adk/tool_wrapper.py +139 -0
- solace_agent_mesh/agent/agent_llm.txt +41 -0
- solace_agent_mesh/agent/protocol/event_handlers.py +1469 -0
- solace_agent_mesh/agent/protocol/protocol_llm.txt +21 -0
- solace_agent_mesh/agent/sac/app.py +640 -0
- solace_agent_mesh/agent/sac/component.py +3388 -0
- solace_agent_mesh/agent/sac/patch_adk.py +111 -0
- solace_agent_mesh/agent/sac/sac_llm.txt +105 -0
- solace_agent_mesh/agent/sac/task_execution_context.py +176 -0
- solace_agent_mesh/agent/testing/__init__.py +3 -0
- solace_agent_mesh/agent/testing/debug_utils.py +135 -0
- solace_agent_mesh/agent/testing/testing_llm.txt +90 -0
- solace_agent_mesh/agent/tools/__init__.py +14 -0
- solace_agent_mesh/agent/tools/audio_tools.py +1622 -0
- solace_agent_mesh/agent/tools/builtin_artifact_tools.py +1954 -0
- solace_agent_mesh/agent/tools/builtin_data_analysis_tools.py +238 -0
- solace_agent_mesh/agent/tools/general_agent_tools.py +569 -0
- solace_agent_mesh/agent/tools/image_tools.py +1184 -0
- solace_agent_mesh/agent/tools/peer_agent_tool.py +289 -0
- solace_agent_mesh/agent/tools/registry.py +36 -0
- solace_agent_mesh/agent/tools/test_tools.py +135 -0
- solace_agent_mesh/agent/tools/tool_definition.py +45 -0
- solace_agent_mesh/agent/tools/tools_llm.txt +104 -0
- solace_agent_mesh/agent/tools/web_tools.py +381 -0
- solace_agent_mesh/agent/utils/artifact_helpers.py +927 -0
- solace_agent_mesh/agent/utils/config_parser.py +47 -0
- solace_agent_mesh/agent/utils/context_helpers.py +60 -0
- solace_agent_mesh/agent/utils/utils_llm.txt +153 -0
- solace_agent_mesh/assets/docs/404.html +16 -0
- solace_agent_mesh/assets/docs/assets/css/styles.906a1503.css +1 -0
- solace_agent_mesh/assets/docs/assets/images/Solace_AI_Framework_With_Broker-85f0a306a9bcdd20b390b7a949f6d862.png +0 -0
- solace_agent_mesh/assets/docs/assets/images/sac-flows-80d5b603c6aafd33e87945680ce0abf3.png +0 -0
- solace_agent_mesh/assets/docs/assets/images/sac_parts_of_a_component-cb3d0424b1d0c17734c5435cca6b4082.png +0 -0
- solace_agent_mesh/assets/docs/assets/js/04989206.674a8007.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/0e682baa.79f0ab22.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/1001.0182a8bd.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/1023fc19.015679ca.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/1039.0bd46aa1.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/149.b797a808.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/1523c6b4.91c7bc01.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/165.6a39807d.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/165.6a39807d.js.LICENSE.txt +9 -0
- solace_agent_mesh/assets/docs/assets/js/166ab619.7d97ccaf.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/17896441.a5e82f9b.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/17896441.a5e82f9b.js.LICENSE.txt +7 -0
- solace_agent_mesh/assets/docs/assets/js/1c6e87d2.23bccffb.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2130.ab9fd314.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/21ceee5f.614fa8dd.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2237.5e477fc6.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2334.622a6395.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/2a9cab12.8909df92.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3219.adc1d663.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/332e10b5.7a103f42.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3624.b524e433.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/375.708d48db.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3834.b6cd790e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/3d406171.f722eaf5.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4250.95455b28.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/42b3f8d8.36090198.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4356.d169ab5b.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/442a8107.5ba94b65.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4458.518e66fa.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4488.c7cc3442.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4494.6ee23046.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4855.fc4444b6.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4866.22daefc0.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4950.ca4caeda.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/4c2787c2.66ee00e9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5388.7a136447.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/55f47984.c484bf96.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5607.081356f8.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5864.b0d0e9de.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5b4258a4.bda20761.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/5e95c892.558d5167.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6143.0a1464c9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6395.e9c73649.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6796.51d2c9b7.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6976.379be23b.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/6978.ee0b945c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/7040.cb436723.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/7195.412f418a.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/7280.3fb73bdb.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/768e31b0.a12673db.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/7845.e33e7c4c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/7900.69516146.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8356.8a379c04.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/85387663.6bf41934.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8567.4732c6b7.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8573.cb04eda5.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8577.1d54e766.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8591.d7c16be6.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/8591.d7c16be6.js.LICENSE.txt +61 -0
- solace_agent_mesh/assets/docs/assets/js/8709.7ecd4047.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8731.49e930c2.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/8908.f9d1b506.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9157.b4093d07.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9278.a4fd875d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/945fb41e.74d728aa.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9616.b75c2f6d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9793.c6d16376.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/9eff14a2.1bf8f61c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/a3a92b25.26ca071f.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/a7bd4aaa.2204d2f7.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/a94703ab.0438dbc2.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/aba21aa0.c42a534c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/aba87c2f.d3e2dcc3.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ae4415af.8e279b5d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/b7006a3a.40b10c9d.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/bac0be12.f50d9bac.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/bb2ef573.207e6990.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/c2c06897.63b76e9e.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/cc969b05.954186d4.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/cd3d4052.ca6eed8c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/ced92a13.fb92e7ca.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/cee5d587.f5b73ca1.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f284c35a.ecc3d195.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/f897a61a.2c2e152c.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/fbfa3e75.aca209c9.js +1 -0
- solace_agent_mesh/assets/docs/assets/js/main.7ed3319f.js +2 -0
- solace_agent_mesh/assets/docs/assets/js/main.7ed3319f.js.LICENSE.txt +81 -0
- solace_agent_mesh/assets/docs/assets/js/runtime~main.d9520ae2.js +1 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/agents/index.html +128 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/architecture/index.html +91 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/cli/index.html +201 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/gateways/index.html +91 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/orchestrator/index.html +55 -0
- solace_agent_mesh/assets/docs/docs/documentation/concepts/plugins/index.html +82 -0
- solace_agent_mesh/assets/docs/docs/documentation/deployment/debugging/index.html +60 -0
- solace_agent_mesh/assets/docs/docs/documentation/deployment/deploy/index.html +48 -0
- solace_agent_mesh/assets/docs/docs/documentation/deployment/observability/index.html +54 -0
- solace_agent_mesh/assets/docs/docs/documentation/enterprise/index.html +17 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/component-overview/index.html +45 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/installation/index.html +76 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/introduction/index.html +150 -0
- solace_agent_mesh/assets/docs/docs/documentation/getting-started/quick-start/index.html +54 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/bedrock-agents/index.html +267 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/custom-agent/index.html +136 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/event-mesh-gateway/index.html +116 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mcp-integration/index.html +80 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/mongodb-integration/index.html +164 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/rest-gateway/index.html +57 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/slack-integration/index.html +72 -0
- solace_agent_mesh/assets/docs/docs/documentation/tutorials/sql-database/index.html +102 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/artifact-management/index.html +99 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/audio-tools/index.html +90 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/data-analysis-tools/index.html +107 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/embeds/index.html +152 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/builtin-tools/index.html +103 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-agents/index.html +170 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/create-gateways/index.html +200 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/creating-service-providers/index.html +54 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/solace-ai-connector/index.html +69 -0
- solace_agent_mesh/assets/docs/docs/documentation/user-guide/structure/index.html +59 -0
- solace_agent_mesh/assets/docs/img/Solace_AI_Framework_README.png +0 -0
- solace_agent_mesh/assets/docs/img/Solace_AI_Framework_With_Broker.png +0 -0
- solace_agent_mesh/assets/docs/img/logo.png +0 -0
- solace_agent_mesh/assets/docs/img/sac-flows.png +0 -0
- solace_agent_mesh/assets/docs/img/sac_parts_of_a_component.png +0 -0
- solace_agent_mesh/assets/docs/img/solace-logo.png +0 -0
- solace_agent_mesh/assets/docs/lunr-index-1753813536522.json +1 -0
- solace_agent_mesh/assets/docs/lunr-index.json +1 -0
- solace_agent_mesh/assets/docs/search-doc-1753813536522.json +1 -0
- solace_agent_mesh/assets/docs/search-doc.json +1 -0
- solace_agent_mesh/assets/docs/sitemap.xml +1 -0
- solace_agent_mesh/cli/__init__.py +1 -1
- solace_agent_mesh/cli/commands/add_cmd/__init__.py +15 -0
- solace_agent_mesh/cli/commands/add_cmd/add_cmd_llm.txt +250 -0
- solace_agent_mesh/cli/commands/add_cmd/agent_cmd.py +659 -0
- solace_agent_mesh/cli/commands/add_cmd/gateway_cmd.py +322 -0
- solace_agent_mesh/cli/commands/add_cmd/web_add_agent_step.py +93 -0
- solace_agent_mesh/cli/commands/add_cmd/web_add_gateway_step.py +118 -0
- solace_agent_mesh/cli/commands/docs_cmd.py +57 -0
- solace_agent_mesh/cli/commands/eval_cmd.py +64 -0
- solace_agent_mesh/cli/commands/init_cmd/__init__.py +404 -0
- solace_agent_mesh/cli/commands/init_cmd/broker_step.py +201 -0
- solace_agent_mesh/cli/commands/init_cmd/directory_step.py +28 -0
- solace_agent_mesh/cli/commands/init_cmd/env_step.py +197 -0
- solace_agent_mesh/cli/commands/init_cmd/init_cmd_llm.txt +365 -0
- solace_agent_mesh/cli/commands/init_cmd/orchestrator_step.py +387 -0
- solace_agent_mesh/cli/commands/init_cmd/project_files_step.py +38 -0
- solace_agent_mesh/cli/commands/init_cmd/web_init_step.py +110 -0
- solace_agent_mesh/cli/commands/init_cmd/webui_gateway_step.py +183 -0
- solace_agent_mesh/cli/commands/plugin_cmd/__init__.py +18 -0
- solace_agent_mesh/cli/commands/plugin_cmd/add_cmd.py +372 -0
- solace_agent_mesh/cli/commands/plugin_cmd/build_cmd.py +86 -0
- solace_agent_mesh/cli/commands/plugin_cmd/catalog_cmd.py +138 -0
- solace_agent_mesh/cli/commands/plugin_cmd/create_cmd.py +309 -0
- solace_agent_mesh/cli/commands/plugin_cmd/official_registry.py +174 -0
- solace_agent_mesh/cli/commands/plugin_cmd/plugin_cmd_llm.txt +305 -0
- solace_agent_mesh/cli/commands/run_cmd.py +158 -0
- solace_agent_mesh/cli/main.py +17 -294
- solace_agent_mesh/cli/utils.py +135 -204
- solace_agent_mesh/client/webui/frontend/static/assets/authCallback-DvlO62me.js +1 -0
- solace_agent_mesh/client/webui/frontend/static/assets/client-bp6u3qVZ.js +49 -0
- solace_agent_mesh/client/webui/frontend/static/assets/favicon-BLgzUch9.ico +0 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-An0a5j5k.js +663 -0
- solace_agent_mesh/client/webui/frontend/static/assets/main-Bu5-4Bac.css +1 -0
- solace_agent_mesh/client/webui/frontend/static/auth-callback.html +14 -0
- solace_agent_mesh/client/webui/frontend/static/index.html +15 -0
- solace_agent_mesh/common/__init__.py +1 -0
- solace_agent_mesh/common/a2a_protocol.py +564 -0
- solace_agent_mesh/common/agent_registry.py +42 -0
- solace_agent_mesh/common/client/__init__.py +4 -0
- solace_agent_mesh/common/client/card_resolver.py +21 -0
- solace_agent_mesh/common/client/client.py +85 -0
- solace_agent_mesh/common/client/client_llm.txt +133 -0
- solace_agent_mesh/common/common_llm.txt +144 -0
- solace_agent_mesh/common/constants.py +1 -14
- solace_agent_mesh/common/middleware/__init__.py +12 -0
- solace_agent_mesh/common/middleware/config_resolver.py +130 -0
- solace_agent_mesh/common/middleware/middleware_llm.txt +174 -0
- solace_agent_mesh/common/middleware/registry.py +125 -0
- solace_agent_mesh/common/server/__init__.py +4 -0
- solace_agent_mesh/common/server/server.py +122 -0
- solace_agent_mesh/common/server/server_llm.txt +169 -0
- solace_agent_mesh/common/server/task_manager.py +291 -0
- solace_agent_mesh/common/server/utils.py +28 -0
- solace_agent_mesh/common/services/__init__.py +4 -0
- solace_agent_mesh/common/services/employee_service.py +162 -0
- solace_agent_mesh/common/services/identity_service.py +129 -0
- solace_agent_mesh/common/services/providers/__init__.py +4 -0
- solace_agent_mesh/common/services/providers/local_file_identity_service.py +148 -0
- solace_agent_mesh/common/services/providers/providers_llm.txt +113 -0
- solace_agent_mesh/common/services/services_llm.txt +132 -0
- solace_agent_mesh/common/types.py +411 -0
- solace_agent_mesh/common/utils/__init__.py +7 -0
- solace_agent_mesh/common/utils/asyncio_macos_fix.py +86 -0
- solace_agent_mesh/common/utils/embeds/__init__.py +33 -0
- solace_agent_mesh/common/utils/embeds/constants.py +55 -0
- solace_agent_mesh/common/utils/embeds/converter.py +452 -0
- solace_agent_mesh/common/utils/embeds/embeds_llm.txt +124 -0
- solace_agent_mesh/common/utils/embeds/evaluators.py +394 -0
- solace_agent_mesh/common/utils/embeds/modifiers.py +816 -0
- solace_agent_mesh/common/utils/embeds/resolver.py +865 -0
- solace_agent_mesh/common/utils/embeds/types.py +14 -0
- solace_agent_mesh/common/utils/in_memory_cache.py +108 -0
- solace_agent_mesh/common/utils/log_formatters.py +44 -0
- solace_agent_mesh/common/utils/mime_helpers.py +106 -0
- solace_agent_mesh/common/utils/push_notification_auth.py +134 -0
- solace_agent_mesh/common/utils/utils_llm.txt +67 -0
- solace_agent_mesh/config_portal/backend/common.py +66 -24
- solace_agent_mesh/config_portal/backend/plugin_catalog/constants.py +23 -0
- solace_agent_mesh/config_portal/backend/plugin_catalog/models.py +49 -0
- solace_agent_mesh/config_portal/backend/plugin_catalog/registry_manager.py +160 -0
- solace_agent_mesh/config_portal/backend/plugin_catalog/scraper.py +525 -0
- solace_agent_mesh/config_portal/backend/plugin_catalog_server.py +216 -0
- solace_agent_mesh/config_portal/backend/server.py +550 -140
- solace_agent_mesh/config_portal/frontend/static/client/assets/_index-DNxCwAGB.js +48 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/components-B7lKcHVY.js +140 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/{entry.client-DX1misIU.js → entry.client-CEumGClk.js} +3 -3
- solace_agent_mesh/config_portal/frontend/static/client/assets/index-DSo1AH_7.js +68 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-d2b54a97.js +1 -0
- solace_agent_mesh/config_portal/frontend/static/client/assets/{root-BApq5dPK.js → root-C4XmHinv.js} +2 -2
- solace_agent_mesh/config_portal/frontend/static/client/assets/root-DxRwaWiE.css +1 -0
- solace_agent_mesh/config_portal/frontend/static/client/index.html +3 -3
- solace_agent_mesh/core_a2a/__init__.py +1 -0
- solace_agent_mesh/core_a2a/core_a2a_llm.txt +88 -0
- solace_agent_mesh/core_a2a/service.py +331 -0
- solace_agent_mesh/evaluation/config_loader.py +657 -0
- solace_agent_mesh/evaluation/evaluator.py +667 -0
- solace_agent_mesh/evaluation/message_organizer.py +568 -0
- solace_agent_mesh/evaluation/report/benchmark_info.html +35 -0
- solace_agent_mesh/evaluation/report/chart_section.html +141 -0
- solace_agent_mesh/evaluation/report/detailed_breakdown.html +28 -0
- solace_agent_mesh/evaluation/report/modal.html +59 -0
- solace_agent_mesh/evaluation/report/modal_chart_functions.js +411 -0
- solace_agent_mesh/evaluation/report/modal_script.js +296 -0
- solace_agent_mesh/evaluation/report/modal_styles.css +340 -0
- solace_agent_mesh/evaluation/report/performance_metrics_styles.css +93 -0
- solace_agent_mesh/evaluation/report/templates/footer.html +2 -0
- solace_agent_mesh/evaluation/report/templates/header.html +340 -0
- solace_agent_mesh/evaluation/report_data_processor.py +972 -0
- solace_agent_mesh/evaluation/report_generator.py +613 -0
- solace_agent_mesh/evaluation/run.py +613 -0
- solace_agent_mesh/evaluation/subscriber.py +872 -0
- solace_agent_mesh/evaluation/summary_builder.py +775 -0
- solace_agent_mesh/evaluation/test_case_loader.py +714 -0
- solace_agent_mesh/gateway/base/__init__.py +1 -0
- solace_agent_mesh/gateway/base/app.py +266 -0
- solace_agent_mesh/gateway/base/base_llm.txt +119 -0
- solace_agent_mesh/gateway/base/component.py +1542 -0
- solace_agent_mesh/gateway/base/task_context.py +74 -0
- solace_agent_mesh/gateway/gateway_llm.txt +125 -0
- solace_agent_mesh/gateway/http_sse/app.py +190 -0
- solace_agent_mesh/gateway/http_sse/component.py +1602 -0
- solace_agent_mesh/gateway/http_sse/components/__init__.py +7 -0
- solace_agent_mesh/gateway/http_sse/components/components_llm.txt +65 -0
- solace_agent_mesh/gateway/http_sse/components/visualization_forwarder_component.py +108 -0
- solace_agent_mesh/gateway/http_sse/dependencies.py +316 -0
- solace_agent_mesh/gateway/http_sse/http_sse_llm.txt +63 -0
- solace_agent_mesh/gateway/http_sse/main.py +442 -0
- solace_agent_mesh/gateway/http_sse/routers/__init__.py +4 -0
- solace_agent_mesh/gateway/http_sse/routers/agents.py +41 -0
- solace_agent_mesh/gateway/http_sse/routers/artifacts.py +821 -0
- solace_agent_mesh/gateway/http_sse/routers/auth.py +212 -0
- solace_agent_mesh/gateway/http_sse/routers/config.py +55 -0
- solace_agent_mesh/gateway/http_sse/routers/people.py +69 -0
- solace_agent_mesh/gateway/http_sse/routers/routers_llm.txt +37 -0
- solace_agent_mesh/gateway/http_sse/routers/sessions.py +80 -0
- solace_agent_mesh/gateway/http_sse/routers/sse.py +138 -0
- solace_agent_mesh/gateway/http_sse/routers/tasks.py +294 -0
- solace_agent_mesh/gateway/http_sse/routers/users.py +59 -0
- solace_agent_mesh/gateway/http_sse/routers/visualization.py +1131 -0
- solace_agent_mesh/gateway/http_sse/services/__init__.py +4 -0
- solace_agent_mesh/gateway/http_sse/services/agent_service.py +69 -0
- solace_agent_mesh/gateway/http_sse/services/people_service.py +158 -0
- solace_agent_mesh/gateway/http_sse/services/services_llm.txt +179 -0
- solace_agent_mesh/gateway/http_sse/services/task_service.py +121 -0
- solace_agent_mesh/gateway/http_sse/session_manager.py +187 -0
- solace_agent_mesh/gateway/http_sse/sse_manager.py +328 -0
- solace_agent_mesh/llm.txt +228 -0
- solace_agent_mesh/llm_detail.txt +2835 -0
- solace_agent_mesh/templates/agent_template.yaml +53 -0
- solace_agent_mesh/templates/eval_backend_template.yaml +54 -0
- solace_agent_mesh/templates/gateway_app_template.py +73 -0
- solace_agent_mesh/templates/gateway_component_template.py +400 -0
- solace_agent_mesh/templates/gateway_config_template.yaml +43 -0
- solace_agent_mesh/templates/main_orchestrator.yaml +55 -0
- solace_agent_mesh/templates/plugin_agent_config_template.yaml +122 -0
- solace_agent_mesh/templates/plugin_custom_config_template.yaml +27 -0
- solace_agent_mesh/templates/plugin_custom_template.py +10 -0
- solace_agent_mesh/templates/plugin_gateway_config_template.yaml +63 -0
- solace_agent_mesh/templates/plugin_pyproject_template.toml +33 -0
- solace_agent_mesh/templates/plugin_readme_template.md +34 -0
- solace_agent_mesh/templates/plugin_tools_template.py +224 -0
- solace_agent_mesh/templates/shared_config.yaml +66 -0
- solace_agent_mesh/templates/templates_llm.txt +147 -0
- solace_agent_mesh/templates/webui.yaml +53 -0
- solace_agent_mesh-1.0.1.dist-info/METADATA +432 -0
- solace_agent_mesh-1.0.1.dist-info/RECORD +359 -0
- solace_agent_mesh-1.0.1.dist-info/entry_points.txt +3 -0
- {solace_agent_mesh-0.2.3.dist-info → solace_agent_mesh-1.0.1.dist-info}/licenses/LICENSE +1 -1
- solace_agent_mesh/agents/base_agent_component.py +0 -226
- solace_agent_mesh/agents/global/actions/agent_state_change.py +0 -54
- solace_agent_mesh/agents/global/actions/clear_history.py +0 -32
- solace_agent_mesh/agents/global/actions/convert_file_to_markdown.py +0 -160
- solace_agent_mesh/agents/global/actions/create_file.py +0 -70
- solace_agent_mesh/agents/global/actions/error_action.py +0 -45
- solace_agent_mesh/agents/global/actions/plantuml_diagram.py +0 -163
- solace_agent_mesh/agents/global/actions/plotly_graph.py +0 -152
- solace_agent_mesh/agents/global/actions/retrieve_file.py +0 -51
- solace_agent_mesh/agents/global/global_agent_component.py +0 -38
- solace_agent_mesh/agents/image_processing/actions/create_image.py +0 -75
- solace_agent_mesh/agents/image_processing/actions/describe_image.py +0 -115
- solace_agent_mesh/agents/image_processing/image_processing_agent_component.py +0 -23
- solace_agent_mesh/agents/slack/__init__.py +0 -1
- solace_agent_mesh/agents/slack/actions/__init__.py +0 -1
- solace_agent_mesh/agents/slack/actions/post_message.py +0 -177
- solace_agent_mesh/agents/slack/slack_agent_component.py +0 -59
- solace_agent_mesh/agents/web_request/actions/do_image_search.py +0 -84
- solace_agent_mesh/agents/web_request/actions/do_news_search.py +0 -47
- solace_agent_mesh/agents/web_request/actions/do_suggestion_search.py +0 -34
- solace_agent_mesh/agents/web_request/actions/do_web_request.py +0 -135
- solace_agent_mesh/agents/web_request/actions/download_file.py +0 -69
- solace_agent_mesh/agents/web_request/web_request_agent_component.py +0 -33
- solace_agent_mesh/assets/web-visualizer/assets/index-D0qORgkg.css +0 -1
- solace_agent_mesh/assets/web-visualizer/assets/index-DnDr1pnu.js +0 -109
- solace_agent_mesh/assets/web-visualizer/index.html +0 -14
- solace_agent_mesh/assets/web-visualizer/vite.svg +0 -1
- solace_agent_mesh/cli/commands/add/__init__.py +0 -3
- solace_agent_mesh/cli/commands/add/add.py +0 -88
- solace_agent_mesh/cli/commands/add/agent.py +0 -110
- solace_agent_mesh/cli/commands/add/copy_from_plugin.py +0 -92
- solace_agent_mesh/cli/commands/add/gateway.py +0 -374
- solace_agent_mesh/cli/commands/build.py +0 -670
- solace_agent_mesh/cli/commands/chat/__init__.py +0 -3
- solace_agent_mesh/cli/commands/chat/chat.py +0 -361
- solace_agent_mesh/cli/commands/config.py +0 -29
- solace_agent_mesh/cli/commands/init/__init__.py +0 -3
- solace_agent_mesh/cli/commands/init/ai_provider_step.py +0 -93
- solace_agent_mesh/cli/commands/init/broker_step.py +0 -99
- solace_agent_mesh/cli/commands/init/builtin_agent_step.py +0 -83
- solace_agent_mesh/cli/commands/init/check_if_already_done.py +0 -13
- solace_agent_mesh/cli/commands/init/create_config_file_step.py +0 -65
- solace_agent_mesh/cli/commands/init/create_other_project_files_step.py +0 -147
- solace_agent_mesh/cli/commands/init/file_service_step.py +0 -73
- solace_agent_mesh/cli/commands/init/init.py +0 -92
- solace_agent_mesh/cli/commands/init/project_structure_step.py +0 -16
- solace_agent_mesh/cli/commands/init/web_init_step.py +0 -32
- solace_agent_mesh/cli/commands/plugin/__init__.py +0 -3
- solace_agent_mesh/cli/commands/plugin/add.py +0 -100
- solace_agent_mesh/cli/commands/plugin/build.py +0 -268
- solace_agent_mesh/cli/commands/plugin/create.py +0 -117
- solace_agent_mesh/cli/commands/plugin/plugin.py +0 -124
- solace_agent_mesh/cli/commands/plugin/remove.py +0 -73
- solace_agent_mesh/cli/commands/run.py +0 -68
- solace_agent_mesh/cli/commands/visualizer.py +0 -138
- solace_agent_mesh/cli/config.py +0 -85
- solace_agent_mesh/common/action.py +0 -91
- solace_agent_mesh/common/action_list.py +0 -37
- solace_agent_mesh/common/action_response.py +0 -340
- solace_agent_mesh/common/mysql_database.py +0 -40
- solace_agent_mesh/common/postgres_database.py +0 -85
- solace_agent_mesh/common/prompt_templates.py +0 -28
- solace_agent_mesh/common/stimulus_utils.py +0 -152
- solace_agent_mesh/common/time.py +0 -24
- solace_agent_mesh/common/utils.py +0 -712
- solace_agent_mesh/config_portal/frontend/static/client/assets/_index-DMmCawWe.js +0 -42
- solace_agent_mesh/config_portal/frontend/static/client/assets/components-ZIfdTbrV.js +0 -191
- solace_agent_mesh/config_portal/frontend/static/client/assets/index-BJHAE5s4.js +0 -17
- solace_agent_mesh/config_portal/frontend/static/client/assets/manifest-dd988f05.js +0 -1
- solace_agent_mesh/config_portal/frontend/static/client/assets/root-DX4gQ516.css +0 -1
- solace_agent_mesh/configs/agent_global.yaml +0 -74
- solace_agent_mesh/configs/agent_image_processing.yaml +0 -82
- solace_agent_mesh/configs/agent_slack.yaml +0 -64
- solace_agent_mesh/configs/agent_web_request.yaml +0 -75
- solace_agent_mesh/configs/conversation_to_file.yaml +0 -56
- solace_agent_mesh/configs/error_catcher.yaml +0 -56
- solace_agent_mesh/configs/monitor.yaml +0 -0
- solace_agent_mesh/configs/monitor_stim_and_errors_to_slack.yaml +0 -109
- solace_agent_mesh/configs/monitor_user_feedback.yaml +0 -58
- solace_agent_mesh/configs/orchestrator.yaml +0 -241
- solace_agent_mesh/configs/service_embedding.yaml +0 -81
- solace_agent_mesh/configs/service_llm.yaml +0 -265
- solace_agent_mesh/configs/visualize_websocket.yaml +0 -55
- solace_agent_mesh/gateway/components/gateway_base.py +0 -47
- solace_agent_mesh/gateway/components/gateway_input.py +0 -278
- solace_agent_mesh/gateway/components/gateway_output.py +0 -298
- solace_agent_mesh/gateway/identity/bamboohr_identity.py +0 -18
- solace_agent_mesh/gateway/identity/identity_base.py +0 -10
- solace_agent_mesh/gateway/identity/identity_provider.py +0 -60
- solace_agent_mesh/gateway/identity/no_identity.py +0 -9
- solace_agent_mesh/gateway/identity/passthru_identity.py +0 -9
- solace_agent_mesh/monitors/base_monitor_component.py +0 -26
- solace_agent_mesh/monitors/feedback/user_feedback_monitor.py +0 -75
- solace_agent_mesh/monitors/stim_and_errors/stim_and_error_monitor.py +0 -560
- solace_agent_mesh/orchestrator/__init__.py +0 -0
- solace_agent_mesh/orchestrator/action_manager.py +0 -237
- solace_agent_mesh/orchestrator/components/__init__.py +0 -0
- solace_agent_mesh/orchestrator/components/orchestrator_action_manager_timeout_component.py +0 -58
- solace_agent_mesh/orchestrator/components/orchestrator_action_response_component.py +0 -179
- solace_agent_mesh/orchestrator/components/orchestrator_register_component.py +0 -107
- solace_agent_mesh/orchestrator/components/orchestrator_stimulus_processor_component.py +0 -527
- solace_agent_mesh/orchestrator/components/orchestrator_streaming_output_component.py +0 -260
- solace_agent_mesh/orchestrator/orchestrator_main.py +0 -172
- solace_agent_mesh/orchestrator/orchestrator_prompt.py +0 -539
- solace_agent_mesh/services/__init__.py +0 -0
- solace_agent_mesh/services/authorization/providers/base_authorization_provider.py +0 -56
- solace_agent_mesh/services/bamboo_hr_service/__init__.py +0 -3
- solace_agent_mesh/services/bamboo_hr_service/bamboo_hr.py +0 -182
- solace_agent_mesh/services/common/__init__.py +0 -4
- solace_agent_mesh/services/common/auto_expiry.py +0 -45
- solace_agent_mesh/services/common/singleton.py +0 -18
- solace_agent_mesh/services/file_service/__init__.py +0 -14
- solace_agent_mesh/services/file_service/file_manager/__init__.py +0 -0
- solace_agent_mesh/services/file_service/file_manager/bucket_file_manager.py +0 -149
- solace_agent_mesh/services/file_service/file_manager/file_manager_base.py +0 -162
- solace_agent_mesh/services/file_service/file_manager/memory_file_manager.py +0 -64
- solace_agent_mesh/services/file_service/file_manager/volume_file_manager.py +0 -106
- solace_agent_mesh/services/file_service/file_service.py +0 -437
- solace_agent_mesh/services/file_service/file_service_constants.py +0 -54
- solace_agent_mesh/services/file_service/file_transformations.py +0 -141
- solace_agent_mesh/services/file_service/file_utils.py +0 -324
- solace_agent_mesh/services/file_service/transformers/__init__.py +0 -5
- solace_agent_mesh/services/history_service/__init__.py +0 -3
- solace_agent_mesh/services/history_service/history_providers/__init__.py +0 -0
- solace_agent_mesh/services/history_service/history_providers/base_history_provider.py +0 -54
- solace_agent_mesh/services/history_service/history_providers/file_history_provider.py +0 -74
- solace_agent_mesh/services/history_service/history_providers/index.py +0 -40
- solace_agent_mesh/services/history_service/history_providers/memory_history_provider.py +0 -33
- solace_agent_mesh/services/history_service/history_providers/mongodb_history_provider.py +0 -66
- solace_agent_mesh/services/history_service/history_providers/redis_history_provider.py +0 -66
- solace_agent_mesh/services/history_service/history_providers/sql_history_provider.py +0 -93
- solace_agent_mesh/services/history_service/history_service.py +0 -413
- solace_agent_mesh/services/history_service/long_term_memory/__init__.py +0 -0
- solace_agent_mesh/services/history_service/long_term_memory/long_term_memory.py +0 -399
- solace_agent_mesh/services/llm_service/components/llm_request_component.py +0 -340
- solace_agent_mesh/services/llm_service/components/llm_service_component_base.py +0 -152
- solace_agent_mesh/services/middleware_service/__init__.py +0 -0
- solace_agent_mesh/services/middleware_service/middleware_service.py +0 -20
- solace_agent_mesh/templates/action.py +0 -38
- solace_agent_mesh/templates/agent.py +0 -29
- solace_agent_mesh/templates/agent.yaml +0 -70
- solace_agent_mesh/templates/gateway-config-template.yaml +0 -6
- solace_agent_mesh/templates/gateway-default-config.yaml +0 -28
- solace_agent_mesh/templates/gateway-flows.yaml +0 -78
- solace_agent_mesh/templates/gateway-header.yaml +0 -16
- solace_agent_mesh/templates/gateway_base.py +0 -15
- solace_agent_mesh/templates/gateway_input.py +0 -98
- solace_agent_mesh/templates/gateway_output.py +0 -71
- solace_agent_mesh/templates/plugin-gateway-default-config.yaml +0 -29
- solace_agent_mesh/templates/plugin-pyproject.toml +0 -30
- solace_agent_mesh/templates/rest-api-default-config.yaml +0 -31
- solace_agent_mesh/templates/rest-api-flows.yaml +0 -81
- solace_agent_mesh/templates/slack-default-config.yaml +0 -16
- solace_agent_mesh/templates/slack-flows.yaml +0 -81
- solace_agent_mesh/templates/solace-agent-mesh-default.yaml +0 -86
- solace_agent_mesh/templates/solace-agent-mesh-plugin-default.yaml +0 -8
- solace_agent_mesh/templates/web-default-config.yaml +0 -10
- solace_agent_mesh/templates/web-flows.yaml +0 -76
- solace_agent_mesh/tools/__init__.py +0 -0
- solace_agent_mesh/tools/components/__init__.py +0 -0
- solace_agent_mesh/tools/components/conversation_formatter.py +0 -111
- solace_agent_mesh/tools/components/file_resolver_component.py +0 -58
- solace_agent_mesh/tools/config/runtime_config.py +0 -26
- solace_agent_mesh-0.2.3.dist-info/METADATA +0 -172
- solace_agent_mesh-0.2.3.dist-info/RECORD +0 -193
- solace_agent_mesh-0.2.3.dist-info/entry_points.txt +0 -3
- /solace_agent_mesh/{agents → agent}/__init__.py +0 -0
- /solace_agent_mesh/{agents/global → agent/adk}/__init__.py +0 -0
- /solace_agent_mesh/{agents/global/actions → agent/protocol}/__init__.py +0 -0
- /solace_agent_mesh/{agents/image_processing → agent/sac}/__init__.py +0 -0
- /solace_agent_mesh/{agents/image_processing/actions → agent/utils}/__init__.py +0 -0
- /solace_agent_mesh/{agents/web_request → config_portal/backend/plugin_catalog}/__init__.py +0 -0
- /solace_agent_mesh/{agents/web_request/actions → evaluation}/__init__.py +0 -0
- /solace_agent_mesh/gateway/{components → http_sse}/__init__.py +0 -0
- {solace_agent_mesh-0.2.3.dist-info → solace_agent_mesh-1.0.1.dist-info}/WHEEL +0 -0
|
@@ -0,0 +1,865 @@
|
|
|
1
|
+
"""
|
|
2
|
+
Contains the main embed resolution functions, including the chain executor.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import json
|
|
7
|
+
from solace_ai_connector.common.log import log
|
|
8
|
+
from typing import Any, Callable, Dict, Optional, Set, Tuple, List, Union
|
|
9
|
+
from .constants import (
|
|
10
|
+
EMBED_REGEX,
|
|
11
|
+
EMBED_DELIMITER_OPEN,
|
|
12
|
+
EMBED_DELIMITER_CLOSE,
|
|
13
|
+
EARLY_EMBED_TYPES,
|
|
14
|
+
LATE_EMBED_TYPES,
|
|
15
|
+
)
|
|
16
|
+
from .evaluators import EMBED_EVALUATORS, _evaluate_artifact_content_embed
|
|
17
|
+
from .modifiers import MODIFIER_DEFINITIONS, _parse_modifier_chain
|
|
18
|
+
from .converter import (
|
|
19
|
+
convert_data,
|
|
20
|
+
serialize_data,
|
|
21
|
+
_parse_string_to_list_of_dicts,
|
|
22
|
+
)
|
|
23
|
+
from .types import DataFormat
|
|
24
|
+
from ..mime_helpers import is_text_based_mime_type
|
|
25
|
+
|
|
26
|
+
try:
|
|
27
|
+
import yaml
|
|
28
|
+
from .converter import PYYAML_AVAILABLE
|
|
29
|
+
except ImportError:
|
|
30
|
+
PYYAML_AVAILABLE = False
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
def _log_data_state(
|
|
34
|
+
log_id: str,
|
|
35
|
+
step: str,
|
|
36
|
+
data: Any,
|
|
37
|
+
data_format: Optional[DataFormat],
|
|
38
|
+
mime_type: Optional[str],
|
|
39
|
+
):
|
|
40
|
+
"""Logs the state of the data at a specific step."""
|
|
41
|
+
data_type = type(data).__name__
|
|
42
|
+
data_size = "N/A"
|
|
43
|
+
data_preview = "N/A"
|
|
44
|
+
|
|
45
|
+
if isinstance(data, (bytes, str, list)):
|
|
46
|
+
data_size = str(len(data))
|
|
47
|
+
elif isinstance(data, dict):
|
|
48
|
+
data_size = f"{len(data)} keys"
|
|
49
|
+
|
|
50
|
+
if isinstance(data, bytes):
|
|
51
|
+
try:
|
|
52
|
+
data_preview = data[:100].decode("utf-8", errors="replace") + (
|
|
53
|
+
"..." if len(data) > 100 else ""
|
|
54
|
+
)
|
|
55
|
+
except Exception:
|
|
56
|
+
data_preview = f"Bytes[{len(data)}]"
|
|
57
|
+
elif isinstance(data, str):
|
|
58
|
+
data_preview = data[:100] + ("..." if len(data) > 100 else "")
|
|
59
|
+
elif isinstance(data, list):
|
|
60
|
+
data_preview = f"List[{len(data)} items]"
|
|
61
|
+
if data and isinstance(data[0], dict):
|
|
62
|
+
data_preview += f" (First item keys: {list(data[0].keys())[:5]}{'...' if len(data[0].keys()) > 5 else ''})"
|
|
63
|
+
elif isinstance(data, dict):
|
|
64
|
+
data_preview = f"Dict[{len(data)} keys: {list(data.keys())[:5]}{'...' if len(data.keys()) > 5 else ''}]"
|
|
65
|
+
else:
|
|
66
|
+
data_preview = str(data)[:100] + ("..." if len(str(data)) > 100 else "")
|
|
67
|
+
|
|
68
|
+
log.info(
|
|
69
|
+
"%s [%s] Format: %s, MimeType: %s, Type: %s, Size: %s, Preview: '%s'",
|
|
70
|
+
log_id,
|
|
71
|
+
step,
|
|
72
|
+
data_format.name if data_format else "None",
|
|
73
|
+
mime_type,
|
|
74
|
+
data_type,
|
|
75
|
+
data_size,
|
|
76
|
+
data_preview,
|
|
77
|
+
)
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
async def _evaluate_artifact_content_embed_with_chain(
|
|
81
|
+
artifact_spec_from_directive: str,
|
|
82
|
+
modifiers_from_directive: List[Tuple[str, str]],
|
|
83
|
+
output_format_from_directive: Optional[str],
|
|
84
|
+
context: Any,
|
|
85
|
+
log_identifier: str,
|
|
86
|
+
config: Optional[Dict] = None,
|
|
87
|
+
current_depth: int = 0,
|
|
88
|
+
visited_artifacts: Optional[Set[Tuple[str, int]]] = None,
|
|
89
|
+
) -> Tuple[str, Optional[str], int]:
|
|
90
|
+
"""
|
|
91
|
+
Loads artifact content, recursively resolves its internal embeds if text-based,
|
|
92
|
+
applies a chain of modifiers, and serializes the final result.
|
|
93
|
+
"""
|
|
94
|
+
log.info(
|
|
95
|
+
"%s [Depth:%d] Starting chain execution for artifact directive: %s",
|
|
96
|
+
log_identifier,
|
|
97
|
+
current_depth,
|
|
98
|
+
artifact_spec_from_directive,
|
|
99
|
+
)
|
|
100
|
+
visited_artifacts = visited_artifacts or set()
|
|
101
|
+
parsed_artifact_spec = artifact_spec_from_directive
|
|
102
|
+
|
|
103
|
+
loaded_content_bytes, original_mime_type, load_error = (
|
|
104
|
+
await _evaluate_artifact_content_embed(
|
|
105
|
+
parsed_artifact_spec, context, log_identifier, config
|
|
106
|
+
)
|
|
107
|
+
)
|
|
108
|
+
|
|
109
|
+
if load_error:
|
|
110
|
+
log.warning(
|
|
111
|
+
"%s [Depth:%d] Error loading initial artifact '%s': %s",
|
|
112
|
+
log_identifier,
|
|
113
|
+
current_depth,
|
|
114
|
+
parsed_artifact_spec,
|
|
115
|
+
load_error,
|
|
116
|
+
)
|
|
117
|
+
err_str = f"[Error loading artifact '{parsed_artifact_spec}': {load_error}]"
|
|
118
|
+
return err_str, load_error, len(err_str.encode("utf-8"))
|
|
119
|
+
|
|
120
|
+
if loaded_content_bytes is None:
|
|
121
|
+
err_msg = f"Internal error - Artifact load for '{parsed_artifact_spec}' returned None content without error."
|
|
122
|
+
log.error("%s %s", log_identifier, err_msg)
|
|
123
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
124
|
+
|
|
125
|
+
current_data: Any = loaded_content_bytes
|
|
126
|
+
current_format: DataFormat = DataFormat.BYTES
|
|
127
|
+
_log_data_state(
|
|
128
|
+
log_identifier,
|
|
129
|
+
f"[Depth:{current_depth}] Initial Load",
|
|
130
|
+
current_data,
|
|
131
|
+
current_format,
|
|
132
|
+
original_mime_type,
|
|
133
|
+
)
|
|
134
|
+
if is_text_based_mime_type(original_mime_type):
|
|
135
|
+
try:
|
|
136
|
+
decoded_content = loaded_content_bytes.decode("utf-8")
|
|
137
|
+
log.debug(
|
|
138
|
+
"%s [Depth:%d] Artifact '%s' is text-based (%s). Attempting recursive embed resolution.",
|
|
139
|
+
log_identifier,
|
|
140
|
+
current_depth,
|
|
141
|
+
parsed_artifact_spec,
|
|
142
|
+
original_mime_type,
|
|
143
|
+
)
|
|
144
|
+
spec_parts = parsed_artifact_spec.split(":", 1)
|
|
145
|
+
filename_for_key = spec_parts[0]
|
|
146
|
+
version_str_for_key = spec_parts[1] if len(spec_parts) > 1 else None
|
|
147
|
+
try:
|
|
148
|
+
version_for_key = (
|
|
149
|
+
int(version_str_for_key) if version_str_for_key else -1
|
|
150
|
+
)
|
|
151
|
+
except ValueError:
|
|
152
|
+
log.warning(
|
|
153
|
+
"%s Could not parse version from '%s' for visited_artifacts key. Loop detection might be affected.",
|
|
154
|
+
log_identifier,
|
|
155
|
+
parsed_artifact_spec,
|
|
156
|
+
)
|
|
157
|
+
version_for_key = -1
|
|
158
|
+
|
|
159
|
+
artifact_key = (filename_for_key, version_for_key)
|
|
160
|
+
new_visited_artifacts = visited_artifacts.copy()
|
|
161
|
+
new_visited_artifacts.add(artifact_key)
|
|
162
|
+
|
|
163
|
+
resolved_string_content = await resolve_embeds_recursively_in_string(
|
|
164
|
+
text=decoded_content,
|
|
165
|
+
context=context,
|
|
166
|
+
resolver_func=evaluate_embed,
|
|
167
|
+
types_to_resolve=EARLY_EMBED_TYPES.union(LATE_EMBED_TYPES),
|
|
168
|
+
log_identifier=log_identifier,
|
|
169
|
+
config=config,
|
|
170
|
+
max_depth=config.get("gateway_recursive_embed_depth", 12),
|
|
171
|
+
current_depth=current_depth + 1,
|
|
172
|
+
visited_artifacts=new_visited_artifacts,
|
|
173
|
+
accumulated_size=0,
|
|
174
|
+
max_total_size=config.get(
|
|
175
|
+
"gateway_max_artifact_resolve_size_bytes", -1
|
|
176
|
+
),
|
|
177
|
+
)
|
|
178
|
+
current_data = resolved_string_content
|
|
179
|
+
current_format = DataFormat.STRING
|
|
180
|
+
_log_data_state(
|
|
181
|
+
log_identifier,
|
|
182
|
+
f"[Depth:{current_depth}] After Recursive Resolution",
|
|
183
|
+
current_data,
|
|
184
|
+
current_format,
|
|
185
|
+
original_mime_type,
|
|
186
|
+
)
|
|
187
|
+
|
|
188
|
+
except UnicodeDecodeError as ude:
|
|
189
|
+
err_msg = f"Failed to decode text-based artifact '{parsed_artifact_spec}' for recursion: {ude}"
|
|
190
|
+
log.warning("%s %s", log_identifier, err_msg)
|
|
191
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
192
|
+
except Exception as recurse_err:
|
|
193
|
+
err_msg = f"Error during recursive resolution of '{parsed_artifact_spec}': {recurse_err}"
|
|
194
|
+
log.exception("%s %s", log_identifier, err_msg)
|
|
195
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
196
|
+
else:
|
|
197
|
+
log.debug(
|
|
198
|
+
"%s [Depth:%d] Artifact '%s' is not text-based (%s). Passing raw bytes to modifier chain.",
|
|
199
|
+
log_identifier,
|
|
200
|
+
current_depth,
|
|
201
|
+
parsed_artifact_spec,
|
|
202
|
+
original_mime_type,
|
|
203
|
+
)
|
|
204
|
+
|
|
205
|
+
if current_format == DataFormat.STRING and original_mime_type:
|
|
206
|
+
normalized_mime_type = original_mime_type.lower()
|
|
207
|
+
log.debug(
|
|
208
|
+
"%s [Depth:%d] Pre-parsing string content with MIME type: %s",
|
|
209
|
+
log_identifier,
|
|
210
|
+
current_depth,
|
|
211
|
+
normalized_mime_type,
|
|
212
|
+
)
|
|
213
|
+
if "json" in normalized_mime_type:
|
|
214
|
+
try:
|
|
215
|
+
current_data = json.loads(current_data)
|
|
216
|
+
current_format = DataFormat.JSON_OBJECT
|
|
217
|
+
log.info(
|
|
218
|
+
"%s [Depth:%d] Pre-parsed string as JSON_OBJECT.",
|
|
219
|
+
log_identifier,
|
|
220
|
+
current_depth,
|
|
221
|
+
)
|
|
222
|
+
except json.JSONDecodeError:
|
|
223
|
+
log.warning(
|
|
224
|
+
"%s [Depth:%d] Failed to pre-parse as JSON despite MIME type '%s'. Content will be treated as STRING.",
|
|
225
|
+
log_identifier,
|
|
226
|
+
current_depth,
|
|
227
|
+
original_mime_type,
|
|
228
|
+
)
|
|
229
|
+
elif "yaml" in normalized_mime_type or "yml" in normalized_mime_type:
|
|
230
|
+
if PYYAML_AVAILABLE:
|
|
231
|
+
try:
|
|
232
|
+
current_data = yaml.safe_load(current_data)
|
|
233
|
+
current_format = DataFormat.JSON_OBJECT
|
|
234
|
+
log.info(
|
|
235
|
+
"%s [Depth:%d] Pre-parsed string as YAML (now JSON_OBJECT).",
|
|
236
|
+
log_identifier,
|
|
237
|
+
current_depth,
|
|
238
|
+
)
|
|
239
|
+
except yaml.YAMLError:
|
|
240
|
+
log.warning(
|
|
241
|
+
"%s [Depth:%d] Failed to pre-parse as YAML despite MIME type '%s'. Content will be treated as STRING.",
|
|
242
|
+
log_identifier,
|
|
243
|
+
current_depth,
|
|
244
|
+
original_mime_type,
|
|
245
|
+
)
|
|
246
|
+
else:
|
|
247
|
+
log.warning(
|
|
248
|
+
"%s [Depth:%d] Skipping YAML pre-parsing for MIME type '%s' because PyYAML is not installed.",
|
|
249
|
+
log_identifier,
|
|
250
|
+
current_depth,
|
|
251
|
+
original_mime_type,
|
|
252
|
+
)
|
|
253
|
+
elif "csv" in normalized_mime_type:
|
|
254
|
+
parsed_data, error_msg = _parse_string_to_list_of_dicts(
|
|
255
|
+
current_data, original_mime_type, log_identifier
|
|
256
|
+
)
|
|
257
|
+
if error_msg is None and parsed_data is not None:
|
|
258
|
+
current_data = parsed_data
|
|
259
|
+
current_format = DataFormat.LIST_OF_DICTS
|
|
260
|
+
log.info(
|
|
261
|
+
"%s [Depth:%d] Pre-parsed string as LIST_OF_DICTS from CSV.",
|
|
262
|
+
log_identifier,
|
|
263
|
+
current_depth,
|
|
264
|
+
)
|
|
265
|
+
else:
|
|
266
|
+
log.warning(
|
|
267
|
+
"%s [Depth:%d] Failed to pre-parse as CSV despite MIME type '%s': %s. Content will be treated as STRING.",
|
|
268
|
+
log_identifier,
|
|
269
|
+
current_depth,
|
|
270
|
+
original_mime_type,
|
|
271
|
+
error_msg,
|
|
272
|
+
)
|
|
273
|
+
|
|
274
|
+
_log_data_state(
|
|
275
|
+
log_identifier,
|
|
276
|
+
f"[Depth:{current_depth}] After Pre-parsing",
|
|
277
|
+
current_data,
|
|
278
|
+
current_format,
|
|
279
|
+
original_mime_type,
|
|
280
|
+
)
|
|
281
|
+
|
|
282
|
+
modifier_index = 0
|
|
283
|
+
for prefix, value in modifiers_from_directive:
|
|
284
|
+
modifier_index += 1
|
|
285
|
+
modifier_step_id = f"Modifier {modifier_index} ({prefix})"
|
|
286
|
+
|
|
287
|
+
modifier_def = MODIFIER_DEFINITIONS.get(prefix)
|
|
288
|
+
if not modifier_def:
|
|
289
|
+
err_msg = f"Unknown modifier prefix: '{prefix}'"
|
|
290
|
+
log.warning("%s %s", log_identifier, err_msg)
|
|
291
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
292
|
+
|
|
293
|
+
modifier_func = modifier_def["function"]
|
|
294
|
+
accepts_formats: List[DataFormat] = modifier_def["accepts"]
|
|
295
|
+
produces_format: DataFormat = modifier_def["produces"]
|
|
296
|
+
|
|
297
|
+
log.info(
|
|
298
|
+
"%s [Depth:%d][%s] Applying modifier: %s:%s (Accepts: %s, Produces: %s)",
|
|
299
|
+
log_identifier,
|
|
300
|
+
current_depth,
|
|
301
|
+
modifier_step_id,
|
|
302
|
+
prefix,
|
|
303
|
+
value[:50] + "...",
|
|
304
|
+
[f.name for f in accepts_formats],
|
|
305
|
+
produces_format.name,
|
|
306
|
+
)
|
|
307
|
+
|
|
308
|
+
if current_format not in accepts_formats:
|
|
309
|
+
target_format_for_modifier = accepts_formats[0]
|
|
310
|
+
log.info(
|
|
311
|
+
"%s [Depth:%d][%s] Current format %s not accepted by %s. Converting to %s...",
|
|
312
|
+
log_identifier,
|
|
313
|
+
current_depth,
|
|
314
|
+
modifier_step_id,
|
|
315
|
+
current_format.name,
|
|
316
|
+
prefix,
|
|
317
|
+
target_format_for_modifier.name,
|
|
318
|
+
)
|
|
319
|
+
_log_data_state(
|
|
320
|
+
log_identifier,
|
|
321
|
+
f"[Depth:{current_depth}] {modifier_step_id} - Before Conversion",
|
|
322
|
+
current_data,
|
|
323
|
+
current_format,
|
|
324
|
+
original_mime_type,
|
|
325
|
+
)
|
|
326
|
+
converted_data, new_format, convert_error = convert_data(
|
|
327
|
+
current_data,
|
|
328
|
+
current_format,
|
|
329
|
+
target_format_for_modifier,
|
|
330
|
+
log_identifier,
|
|
331
|
+
original_mime_type,
|
|
332
|
+
)
|
|
333
|
+
if convert_error:
|
|
334
|
+
err_msg = (
|
|
335
|
+
f"Failed to convert data for modifier '{prefix}': {convert_error}"
|
|
336
|
+
)
|
|
337
|
+
log.warning("%s %s", log_identifier, err_msg)
|
|
338
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
339
|
+
current_data = converted_data
|
|
340
|
+
current_format = new_format
|
|
341
|
+
log.info(
|
|
342
|
+
"%s [Depth:%d][%s] Conversion successful. New format: %s",
|
|
343
|
+
log_identifier,
|
|
344
|
+
current_depth,
|
|
345
|
+
modifier_step_id,
|
|
346
|
+
current_format.name,
|
|
347
|
+
)
|
|
348
|
+
_log_data_state(
|
|
349
|
+
log_identifier,
|
|
350
|
+
f"[Depth:{current_depth}] {modifier_step_id} - After Conversion",
|
|
351
|
+
current_data,
|
|
352
|
+
current_format,
|
|
353
|
+
original_mime_type,
|
|
354
|
+
)
|
|
355
|
+
|
|
356
|
+
try:
|
|
357
|
+
_log_data_state(
|
|
358
|
+
log_identifier,
|
|
359
|
+
f"[Depth:{current_depth}] {modifier_step_id} - Before Execution",
|
|
360
|
+
current_data,
|
|
361
|
+
current_format,
|
|
362
|
+
original_mime_type,
|
|
363
|
+
)
|
|
364
|
+
if prefix == "apply_to_template":
|
|
365
|
+
result_data, _, exec_error = await modifier_func(
|
|
366
|
+
current_data, value, original_mime_type, log_identifier, context
|
|
367
|
+
)
|
|
368
|
+
else:
|
|
369
|
+
if asyncio.iscoroutinefunction(modifier_func):
|
|
370
|
+
result_data, _, exec_error = await modifier_func(
|
|
371
|
+
current_data, value, original_mime_type, log_identifier
|
|
372
|
+
)
|
|
373
|
+
else:
|
|
374
|
+
result_data, _, exec_error = modifier_func(
|
|
375
|
+
current_data, value, original_mime_type, log_identifier
|
|
376
|
+
)
|
|
377
|
+
|
|
378
|
+
if exec_error:
|
|
379
|
+
err_msg = f"Error applying modifier '{prefix}': {exec_error}"
|
|
380
|
+
log.warning("%s %s", log_identifier, err_msg)
|
|
381
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
382
|
+
|
|
383
|
+
current_data = result_data
|
|
384
|
+
current_format = produces_format
|
|
385
|
+
log.info(
|
|
386
|
+
"%s [Depth:%d][%s] Modifier '%s' executed. Result format: %s",
|
|
387
|
+
log_identifier,
|
|
388
|
+
current_depth,
|
|
389
|
+
modifier_step_id,
|
|
390
|
+
prefix,
|
|
391
|
+
current_format.name,
|
|
392
|
+
)
|
|
393
|
+
_log_data_state(
|
|
394
|
+
log_identifier,
|
|
395
|
+
f"[Depth:{current_depth}] {modifier_step_id} - After Execution",
|
|
396
|
+
current_data,
|
|
397
|
+
current_format,
|
|
398
|
+
original_mime_type,
|
|
399
|
+
)
|
|
400
|
+
if current_data is None or (
|
|
401
|
+
isinstance(current_data, (list, str, bytes)) and not current_data
|
|
402
|
+
):
|
|
403
|
+
log.info(
|
|
404
|
+
"%s [Depth:%d][%s] Modifier '%s' resulted in empty data.",
|
|
405
|
+
log_identifier,
|
|
406
|
+
current_depth,
|
|
407
|
+
modifier_step_id,
|
|
408
|
+
prefix,
|
|
409
|
+
)
|
|
410
|
+
|
|
411
|
+
except Exception as mod_err:
|
|
412
|
+
log.exception(
|
|
413
|
+
"%s [Depth:%d][%s] Unexpected error executing modifier '%s': %s",
|
|
414
|
+
log_identifier,
|
|
415
|
+
current_depth,
|
|
416
|
+
modifier_step_id,
|
|
417
|
+
prefix,
|
|
418
|
+
mod_err,
|
|
419
|
+
)
|
|
420
|
+
err_msg = f"Unexpected error in modifier '{prefix}': {mod_err}"
|
|
421
|
+
return f"[Error: {err_msg}]", err_msg, 0
|
|
422
|
+
|
|
423
|
+
target_string_format = output_format_from_directive
|
|
424
|
+
if target_string_format is None:
|
|
425
|
+
log.warning(
|
|
426
|
+
"%s [Depth:%d] Missing final 'format:' step in chain. Defaulting to 'text'.",
|
|
427
|
+
log_identifier,
|
|
428
|
+
current_depth,
|
|
429
|
+
)
|
|
430
|
+
target_string_format = "text"
|
|
431
|
+
|
|
432
|
+
log.info(
|
|
433
|
+
"%s [Depth:%d] [Final Serialization] Serializing final data (Format: %s) to target string format '%s'",
|
|
434
|
+
log_identifier,
|
|
435
|
+
current_depth,
|
|
436
|
+
current_format.name,
|
|
437
|
+
target_string_format,
|
|
438
|
+
)
|
|
439
|
+
_log_data_state(
|
|
440
|
+
log_identifier,
|
|
441
|
+
f"[Depth:{current_depth}] Before Serialization",
|
|
442
|
+
current_data,
|
|
443
|
+
current_format,
|
|
444
|
+
original_mime_type,
|
|
445
|
+
)
|
|
446
|
+
|
|
447
|
+
final_serialized_string, serialize_error = serialize_data(
|
|
448
|
+
data=current_data,
|
|
449
|
+
data_format=current_format,
|
|
450
|
+
target_string_format=target_string_format,
|
|
451
|
+
original_mime_type=original_mime_type,
|
|
452
|
+
log_id=log_identifier,
|
|
453
|
+
)
|
|
454
|
+
|
|
455
|
+
if serialize_error:
|
|
456
|
+
log.warning("%s [Depth:%d] %s", log_identifier, current_depth, serialize_error)
|
|
457
|
+
return (
|
|
458
|
+
final_serialized_string,
|
|
459
|
+
serialize_error,
|
|
460
|
+
len(final_serialized_string.encode("utf-8")),
|
|
461
|
+
)
|
|
462
|
+
|
|
463
|
+
final_size = len(final_serialized_string.encode("utf-8"))
|
|
464
|
+
log.info(
|
|
465
|
+
"%s [Depth:%d] Chain execution completed successfully. Final size: %d bytes.",
|
|
466
|
+
log_identifier,
|
|
467
|
+
current_depth,
|
|
468
|
+
final_size,
|
|
469
|
+
)
|
|
470
|
+
log.info(
|
|
471
|
+
"%s [Depth:%d] [Final Serialization] Result: '%s...'",
|
|
472
|
+
log_identifier,
|
|
473
|
+
current_depth,
|
|
474
|
+
final_serialized_string[:100]
|
|
475
|
+
+ ("..." if len(final_serialized_string) > 100 else ""),
|
|
476
|
+
)
|
|
477
|
+
return final_serialized_string, None, final_size
|
|
478
|
+
|
|
479
|
+
|
|
480
|
+
async def resolve_embeds_in_string(
|
|
481
|
+
text: str,
|
|
482
|
+
context: Any,
|
|
483
|
+
resolver_func: Callable[
|
|
484
|
+
..., Union[Tuple[str, Optional[str], int], Tuple[None, str, Any]]
|
|
485
|
+
],
|
|
486
|
+
types_to_resolve: Set[str],
|
|
487
|
+
log_identifier: str = "[EmbedUtil]",
|
|
488
|
+
config: Optional[Dict[str, Any]] = None,
|
|
489
|
+
) -> Tuple[str, int, List[Tuple[int, Any]]]:
|
|
490
|
+
"""
|
|
491
|
+
Resolves specified embed types within a string using a provided resolver function.
|
|
492
|
+
This is the TOP-LEVEL resolver called by gateways. It handles signals and buffering.
|
|
493
|
+
It does NOT perform recursion itself but calls `evaluate_embed` which might trigger recursion.
|
|
494
|
+
|
|
495
|
+
Processes the string iteratively, resolving one embed at a time.
|
|
496
|
+
Includes buffering logic: stops processing if a partial embed delimiter is found
|
|
497
|
+
at the end, returning the processed part and the index where processing stopped.
|
|
498
|
+
Can now return special signals from the resolver function.
|
|
499
|
+
|
|
500
|
+
Args:
|
|
501
|
+
text: The input string potentially containing embeds.
|
|
502
|
+
context: The context object passed to the resolver function (now a Dict).
|
|
503
|
+
resolver_func: The function to call for evaluating each embed.
|
|
504
|
+
Signature: (type, expression, format, context, log_id, config, ...) -> Any
|
|
505
|
+
Can return a string for replacement, or a tuple like (None, "SIGNAL_TYPE", data)
|
|
506
|
+
to indicate a signal instead of text replacement.
|
|
507
|
+
types_to_resolve: A set of embed types (strings) to resolve in this pass.
|
|
508
|
+
log_identifier: Identifier for logging.
|
|
509
|
+
config: Optional configuration dictionary passed to the resolver.
|
|
510
|
+
|
|
511
|
+
Returns:
|
|
512
|
+
A tuple containing:
|
|
513
|
+
- The string with specified embeds resolved (or removed if signaled).
|
|
514
|
+
- The index in the *original* string representing the end of the
|
|
515
|
+
successfully processed portion (useful for buffering). This will be
|
|
516
|
+
len(text) if the whole string was processed.
|
|
517
|
+
- A list of signals encountered during resolution, as tuples (index, signal_data).
|
|
518
|
+
The index corresponds to the start index of the embed directive in the original string.
|
|
519
|
+
"""
|
|
520
|
+
resolved_parts = []
|
|
521
|
+
signals_found: List[Tuple[int, Any]] = []
|
|
522
|
+
last_end = 0
|
|
523
|
+
original_length = len(text)
|
|
524
|
+
|
|
525
|
+
log.debug(
|
|
526
|
+
"%s Checking for embeds in text: '%s'", log_identifier, text[:200] + "..."
|
|
527
|
+
)
|
|
528
|
+
|
|
529
|
+
for match in EMBED_REGEX.finditer(text):
|
|
530
|
+
start, end = match.span()
|
|
531
|
+
embed_type = match.group(1)
|
|
532
|
+
expression = match.group(2)
|
|
533
|
+
format_spec = match.group(3)
|
|
534
|
+
|
|
535
|
+
resolved_parts.append(text[last_end:start])
|
|
536
|
+
|
|
537
|
+
if embed_type in types_to_resolve:
|
|
538
|
+
log.info(
|
|
539
|
+
"%s Found embed type '%s' to resolve: expr='%s', fmt='%s'",
|
|
540
|
+
log_identifier,
|
|
541
|
+
embed_type,
|
|
542
|
+
expression,
|
|
543
|
+
format_spec,
|
|
544
|
+
)
|
|
545
|
+
resolved_value = await resolver_func(
|
|
546
|
+
embed_type,
|
|
547
|
+
expression,
|
|
548
|
+
format_spec,
|
|
549
|
+
context,
|
|
550
|
+
log_identifier,
|
|
551
|
+
config,
|
|
552
|
+
)
|
|
553
|
+
|
|
554
|
+
if (
|
|
555
|
+
isinstance(resolved_value, tuple)
|
|
556
|
+
and len(resolved_value) == 3
|
|
557
|
+
and resolved_value[0] is None
|
|
558
|
+
and isinstance(resolved_value[1], str)
|
|
559
|
+
):
|
|
560
|
+
signal_type = resolved_value[1]
|
|
561
|
+
log.info(
|
|
562
|
+
"%s Received signal '%s' from resolver for embed at index %d.",
|
|
563
|
+
log_identifier,
|
|
564
|
+
signal_type,
|
|
565
|
+
start,
|
|
566
|
+
)
|
|
567
|
+
signals_found.append(
|
|
568
|
+
(
|
|
569
|
+
start,
|
|
570
|
+
resolved_value,
|
|
571
|
+
)
|
|
572
|
+
)
|
|
573
|
+
elif (
|
|
574
|
+
isinstance(resolved_value, tuple)
|
|
575
|
+
and len(resolved_value) == 3
|
|
576
|
+
and isinstance(resolved_value[0], str)
|
|
577
|
+
and isinstance(resolved_value[2], int)
|
|
578
|
+
):
|
|
579
|
+
text_content, error_message, _ = resolved_value
|
|
580
|
+
if error_message:
|
|
581
|
+
log.warning(
|
|
582
|
+
"%s Embed resolution for '%s:%s' resulted in error: %s. Using error string as content.",
|
|
583
|
+
log_identifier,
|
|
584
|
+
embed_type,
|
|
585
|
+
expression,
|
|
586
|
+
error_message,
|
|
587
|
+
)
|
|
588
|
+
resolved_parts.append(text_content)
|
|
589
|
+
else:
|
|
590
|
+
log.warning(
|
|
591
|
+
"%s Resolver for type '%s' returned unexpected structure %s. Treating as error string.",
|
|
592
|
+
log_identifier,
|
|
593
|
+
embed_type,
|
|
594
|
+
type(resolved_value),
|
|
595
|
+
)
|
|
596
|
+
|
|
597
|
+
else:
|
|
598
|
+
log.debug(
|
|
599
|
+
"%s Skipping embed type '%s' (not in types_to_resolve)",
|
|
600
|
+
log_identifier,
|
|
601
|
+
embed_type,
|
|
602
|
+
)
|
|
603
|
+
resolved_parts.append(match.group(0))
|
|
604
|
+
|
|
605
|
+
last_end = end
|
|
606
|
+
|
|
607
|
+
remaining_text = text[last_end:]
|
|
608
|
+
resolved_parts.append(remaining_text)
|
|
609
|
+
|
|
610
|
+
potential_partial_embed = False
|
|
611
|
+
partial_embed_start_index = -1
|
|
612
|
+
|
|
613
|
+
last_open_delimiter_index = remaining_text.rfind(EMBED_DELIMITER_OPEN)
|
|
614
|
+
|
|
615
|
+
if last_open_delimiter_index != -1:
|
|
616
|
+
closing_delimiter_index = remaining_text.find(
|
|
617
|
+
EMBED_DELIMITER_CLOSE, last_open_delimiter_index
|
|
618
|
+
)
|
|
619
|
+
if closing_delimiter_index == -1:
|
|
620
|
+
potential_partial_embed = True
|
|
621
|
+
partial_embed_start_index = last_open_delimiter_index
|
|
622
|
+
log.debug(
|
|
623
|
+
"%s Potential unclosed embed detected starting at index %d within remaining text: '%s...'",
|
|
624
|
+
log_identifier,
|
|
625
|
+
partial_embed_start_index,
|
|
626
|
+
remaining_text[
|
|
627
|
+
partial_embed_start_index : partial_embed_start_index + 10
|
|
628
|
+
],
|
|
629
|
+
)
|
|
630
|
+
|
|
631
|
+
if potential_partial_embed:
|
|
632
|
+
processed_until_index = last_end + partial_embed_start_index
|
|
633
|
+
final_text = (
|
|
634
|
+
"".join(resolved_parts[:-1]) + remaining_text[:partial_embed_start_index]
|
|
635
|
+
)
|
|
636
|
+
log.debug(
|
|
637
|
+
"%s Returning processed text up to index %d due to potential partial embed.",
|
|
638
|
+
log_identifier,
|
|
639
|
+
processed_until_index,
|
|
640
|
+
)
|
|
641
|
+
else:
|
|
642
|
+
final_text = "".join(resolved_parts)
|
|
643
|
+
processed_until_index = original_length
|
|
644
|
+
log.debug(
|
|
645
|
+
"%s Returning fully processed text (length %d).",
|
|
646
|
+
log_identifier,
|
|
647
|
+
len(final_text),
|
|
648
|
+
)
|
|
649
|
+
|
|
650
|
+
return final_text, processed_until_index, signals_found
|
|
651
|
+
|
|
652
|
+
|
|
653
|
+
async def resolve_embeds_recursively_in_string(
|
|
654
|
+
text: str,
|
|
655
|
+
context: Any,
|
|
656
|
+
resolver_func: Callable[..., Tuple[str, Optional[str], int]],
|
|
657
|
+
types_to_resolve: Set[str],
|
|
658
|
+
log_identifier: str,
|
|
659
|
+
config: Optional[Dict],
|
|
660
|
+
max_depth: int,
|
|
661
|
+
current_depth: int = 0,
|
|
662
|
+
visited_artifacts: Optional[Set[Tuple[str, int]]] = None,
|
|
663
|
+
accumulated_size: int = 0,
|
|
664
|
+
max_total_size: int = -1,
|
|
665
|
+
) -> str:
|
|
666
|
+
"""
|
|
667
|
+
Recursively resolves specified embed types within a string, respecting depth,
|
|
668
|
+
loop detection (via visited_artifacts passed down), and accumulated size limits.
|
|
669
|
+
"""
|
|
670
|
+
if current_depth >= max_depth:
|
|
671
|
+
log.warning(
|
|
672
|
+
"%s Max embed recursion depth (%d) reached for current processing string.",
|
|
673
|
+
log_identifier,
|
|
674
|
+
max_depth,
|
|
675
|
+
)
|
|
676
|
+
return "[Error: Max embed depth exceeded]"
|
|
677
|
+
|
|
678
|
+
visited_artifacts = visited_artifacts or set()
|
|
679
|
+
resolved_parts = []
|
|
680
|
+
last_end = 0
|
|
681
|
+
|
|
682
|
+
for match in EMBED_REGEX.finditer(text):
|
|
683
|
+
start, end = match.span()
|
|
684
|
+
embed_type = match.group(1)
|
|
685
|
+
expression = match.group(2)
|
|
686
|
+
format_spec = match.group(3)
|
|
687
|
+
|
|
688
|
+
resolved_parts.append(text[last_end:start])
|
|
689
|
+
|
|
690
|
+
if embed_type not in types_to_resolve:
|
|
691
|
+
resolved_parts.append(match.group(0))
|
|
692
|
+
last_end = end
|
|
693
|
+
continue
|
|
694
|
+
|
|
695
|
+
log.debug(
|
|
696
|
+
"%s [Depth:%d] Found embed '%s' to resolve: expr='%s', fmt='%s'",
|
|
697
|
+
log_identifier,
|
|
698
|
+
current_depth,
|
|
699
|
+
embed_type,
|
|
700
|
+
expression,
|
|
701
|
+
format_spec,
|
|
702
|
+
)
|
|
703
|
+
|
|
704
|
+
resolved_value = await resolver_func(
|
|
705
|
+
embed_type,
|
|
706
|
+
expression,
|
|
707
|
+
format_spec,
|
|
708
|
+
context,
|
|
709
|
+
log_identifier,
|
|
710
|
+
config,
|
|
711
|
+
current_depth,
|
|
712
|
+
visited_artifacts,
|
|
713
|
+
)
|
|
714
|
+
|
|
715
|
+
if (
|
|
716
|
+
isinstance(resolved_value, tuple)
|
|
717
|
+
and len(resolved_value) == 3
|
|
718
|
+
and isinstance(resolved_value[0], str)
|
|
719
|
+
and isinstance(resolved_value[2], int)
|
|
720
|
+
):
|
|
721
|
+
resolved_string_for_embed, error_msg_from_chain, size_of_this_embed = (
|
|
722
|
+
resolved_value
|
|
723
|
+
)
|
|
724
|
+
else:
|
|
725
|
+
log.error(
|
|
726
|
+
"%s [Depth:%d] Recursive call to resolver for '%s:%s' returned unexpected signal or format. Treating as error.",
|
|
727
|
+
log_identifier,
|
|
728
|
+
current_depth,
|
|
729
|
+
embed_type,
|
|
730
|
+
expression,
|
|
731
|
+
)
|
|
732
|
+
error_msg_from_chain = "Recursive resolution returned unexpected signal."
|
|
733
|
+
resolved_string_for_embed = f"[Error: {error_msg_from_chain}]"
|
|
734
|
+
size_of_this_embed = len(resolved_string_for_embed.encode("utf-8"))
|
|
735
|
+
|
|
736
|
+
if error_msg_from_chain:
|
|
737
|
+
log.warning(
|
|
738
|
+
"%s [Depth:%d] Embed '%s:%s' resulted in error from chain: %s",
|
|
739
|
+
log_identifier,
|
|
740
|
+
current_depth,
|
|
741
|
+
embed_type,
|
|
742
|
+
expression,
|
|
743
|
+
error_msg_from_chain,
|
|
744
|
+
)
|
|
745
|
+
resolved_parts.append(resolved_string_for_embed)
|
|
746
|
+
else:
|
|
747
|
+
if (
|
|
748
|
+
max_total_size >= 0
|
|
749
|
+
and accumulated_size + size_of_this_embed > max_total_size
|
|
750
|
+
):
|
|
751
|
+
error_str = f"[Error: Embedding '{expression}' exceeds total size limit for parent content ({accumulated_size + size_of_this_embed} > {max_total_size})]"
|
|
752
|
+
log.warning("%s %s", log_identifier, error_str)
|
|
753
|
+
resolved_parts.append(error_str)
|
|
754
|
+
else:
|
|
755
|
+
resolved_parts.append(resolved_string_for_embed)
|
|
756
|
+
accumulated_size += size_of_this_embed
|
|
757
|
+
log.debug(
|
|
758
|
+
"%s [Depth:%d] Appended resolved embed (size: %d). Current accumulated_size: %d",
|
|
759
|
+
log_identifier,
|
|
760
|
+
current_depth,
|
|
761
|
+
size_of_this_embed,
|
|
762
|
+
accumulated_size,
|
|
763
|
+
)
|
|
764
|
+
|
|
765
|
+
last_end = end
|
|
766
|
+
|
|
767
|
+
resolved_parts.append(text[last_end:])
|
|
768
|
+
return "".join(resolved_parts)
|
|
769
|
+
|
|
770
|
+
|
|
771
|
+
async def evaluate_embed(
|
|
772
|
+
embed_type: str,
|
|
773
|
+
expression: str,
|
|
774
|
+
format_spec: Optional[str],
|
|
775
|
+
context: Dict[str, Any],
|
|
776
|
+
log_identifier: str,
|
|
777
|
+
config: Optional[Dict] = None,
|
|
778
|
+
current_depth: int = 0,
|
|
779
|
+
visited_artifacts: Optional[Set[Tuple[str, int]]] = None,
|
|
780
|
+
) -> Union[Tuple[str, Optional[str], int], Tuple[None, str, Any]]:
|
|
781
|
+
"""
|
|
782
|
+
Evaluates a single embed directive.
|
|
783
|
+
For 'artifact_content', it handles the modifier chain and potential internal recursion.
|
|
784
|
+
For other types, it evaluates directly and returns a 3-tuple (text, error, size).
|
|
785
|
+
For 'status_update', it returns a signal tuple (None, "SIGNAL_STATUS_UPDATE", data).
|
|
786
|
+
|
|
787
|
+
Args:
|
|
788
|
+
embed_type: The type of the embed.
|
|
789
|
+
expression: The expression part of the embed.
|
|
790
|
+
format_spec: The optional format specifier.
|
|
791
|
+
context: The dictionary-based context (containing artifact_service, session_context, config).
|
|
792
|
+
log_identifier: Identifier for logging.
|
|
793
|
+
config: Optional configuration dictionary (now part of context or passed if needed by evaluators).
|
|
794
|
+
current_depth: Current recursion depth (for artifact_content).
|
|
795
|
+
visited_artifacts: Set of visited artifacts (for artifact_content).
|
|
796
|
+
|
|
797
|
+
Returns:
|
|
798
|
+
A 3-tuple (text_content, error_message, size) or a signal tuple (None, signal_type, data).
|
|
799
|
+
"""
|
|
800
|
+
log.debug(
|
|
801
|
+
"%s Evaluating embed: type='%s', expr='%s', fmt='%s'",
|
|
802
|
+
log_identifier,
|
|
803
|
+
embed_type,
|
|
804
|
+
expression[:50] + "...",
|
|
805
|
+
format_spec,
|
|
806
|
+
)
|
|
807
|
+
|
|
808
|
+
if embed_type == "status_update":
|
|
809
|
+
status_text = expression.strip()
|
|
810
|
+
log.info("%s Detected 'status_update' embed. Signaling.", log_identifier)
|
|
811
|
+
return (None, "SIGNAL_STATUS_UPDATE", status_text)
|
|
812
|
+
|
|
813
|
+
elif embed_type == "artifact_content":
|
|
814
|
+
artifact_spec, modifiers, output_format = _parse_modifier_chain(expression)
|
|
815
|
+
if output_format is None and format_spec is not None:
|
|
816
|
+
log.warning(
|
|
817
|
+
"%s Using format specifier '| %s' for artifact_content as chain format step was missing.",
|
|
818
|
+
log_identifier,
|
|
819
|
+
format_spec,
|
|
820
|
+
)
|
|
821
|
+
output_format = format_spec
|
|
822
|
+
|
|
823
|
+
final_string, error, size = await _evaluate_artifact_content_embed_with_chain(
|
|
824
|
+
artifact_spec_from_directive=artifact_spec,
|
|
825
|
+
modifiers_from_directive=modifiers,
|
|
826
|
+
output_format_from_directive=output_format,
|
|
827
|
+
context=context,
|
|
828
|
+
log_identifier=log_identifier,
|
|
829
|
+
config=config,
|
|
830
|
+
current_depth=current_depth,
|
|
831
|
+
visited_artifacts=visited_artifacts or set(),
|
|
832
|
+
)
|
|
833
|
+
return final_string, error, size
|
|
834
|
+
|
|
835
|
+
else:
|
|
836
|
+
evaluator = EMBED_EVALUATORS.get(embed_type)
|
|
837
|
+
if not evaluator:
|
|
838
|
+
err_msg = f"Unknown embed type: '{embed_type}'"
|
|
839
|
+
log.warning("%s %s", log_identifier, err_msg)
|
|
840
|
+
err_str = f"[Error: {err_msg}]"
|
|
841
|
+
return err_str, err_msg, len(err_str.encode("utf-8"))
|
|
842
|
+
|
|
843
|
+
try:
|
|
844
|
+
if asyncio.iscoroutinefunction(evaluator):
|
|
845
|
+
str_value, eval_error, size = await evaluator(
|
|
846
|
+
expression, context, log_identifier, format_spec
|
|
847
|
+
)
|
|
848
|
+
else:
|
|
849
|
+
str_value, eval_error, size = evaluator(
|
|
850
|
+
expression, context, log_identifier, format_spec
|
|
851
|
+
)
|
|
852
|
+
|
|
853
|
+
return str_value, eval_error, size
|
|
854
|
+
|
|
855
|
+
except Exception as e:
|
|
856
|
+
log.exception(
|
|
857
|
+
"%s Unexpected error evaluating %s embed '%s': %s",
|
|
858
|
+
log_identifier,
|
|
859
|
+
embed_type,
|
|
860
|
+
expression,
|
|
861
|
+
e,
|
|
862
|
+
)
|
|
863
|
+
err_msg = f"Unexpected evaluation error: {e}"
|
|
864
|
+
err_str = f"[Error: {err_msg}]"
|
|
865
|
+
return err_str, err_msg, len(err_str.encode("utf-8"))
|