rasa-pro 3.22.0.dev1__py3-none-any.whl → 3.22.0.dev2__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.
- rasa/agents/protocol/a2a/a2a_agent.py +1 -1
- rasa/agents/protocol/mcp/mcp_base_agent.py +1 -1
- rasa/builder/agent_plan/builder.py +5 -1
- rasa/builder/agent_plan/models.py +6 -0
- rasa/builder/agent_plan/planner.py +44 -12
- rasa/builder/agent_plan/store.py +166 -83
- rasa/builder/agent_skills.py +228 -4
- rasa/builder/behavior_editing.py +21 -130
- rasa/builder/branches.py +252 -2
- rasa/builder/config.py +17 -0
- rasa/builder/constants.py +6 -0
- rasa/builder/copilot/constants.py +3 -0
- rasa/builder/copilot/mcp_server/INSTRUCTIONS.md +1 -1
- rasa/builder/copilot/mcp_server/constants.py +29 -4
- rasa/builder/copilot/mcp_server/models.py +58 -1
- rasa/builder/copilot/mcp_server/server.py +429 -46
- rasa/builder/copilot/mcp_server/tools/artifact_writer.py +250 -20
- rasa/builder/copilot/mcp_server/tools/eval_errors.py +18 -0
- rasa/builder/copilot/mcp_server/tools/evaluate_agent.py +138 -40
- rasa/builder/copilot/mcp_server/tools/rasa_http.py +44 -0
- rasa/builder/copilot/mcp_server/tools/remote_eval.py +284 -0
- rasa/builder/copilot/mcp_server/tools/text_simulation.py +6 -3
- rasa/builder/copilot/message_classifier/message_classifier.py +1 -1
- rasa/builder/copilot/preflight.py +22 -4
- rasa/builder/copilot/pydantic_ai/actions.py +142 -0
- rasa/builder/copilot/pydantic_ai/ag_ui_events.py +16 -0
- rasa/builder/copilot/pydantic_ai/agent.py +149 -18
- rasa/builder/copilot/pydantic_ai/api.py +6 -0
- rasa/builder/copilot/pydantic_ai/branch_tool.py +13 -7
- rasa/builder/copilot/pydantic_ai/document_search.py +7 -1
- rasa/builder/copilot/pydantic_ai/event_mapper.py +22 -6
- rasa/builder/copilot/pydantic_ai/hooks.py +46 -9
- rasa/builder/copilot/pydantic_ai/instrumentation.py +10 -4
- rasa/builder/copilot/pydantic_ai/persisted_messages.py +53 -2
- rasa/builder/copilot/pydantic_ai/prompt_loader.py +40 -30
- rasa/builder/copilot/pydantic_ai/remote_eval.py +61 -0
- rasa/builder/copilot/pydantic_ai/run_context.py +16 -0
- rasa/builder/copilot/pydantic_ai/thread_store.py +217 -47
- rasa/builder/copilot/pydantic_ai/train_tool.py +39 -0
- rasa/builder/copilot/pydantic_ai/widgets.py +165 -0
- rasa/builder/copilot/skills/mantle/docs-lookup/SKILL.md +1 -1
- rasa/builder/copilot/skills/mantle/simulating-evaluating/SKILL.md +54 -18
- rasa/builder/copilot/skills/mantle/testing-debugging/SKILL.md +8 -8
- rasa/builder/document_retrieval/local/data/docs_vectors.parquet +0 -0
- rasa/builder/document_retrieval/local/data/mantle_docs_vectors.parquet +0 -0
- rasa/builder/download.py +5 -77
- rasa/builder/eval_batches.py +152 -0
- rasa/builder/evaluator/dataset/data_gen/retrieval/process_langfuse_traces.py +81 -37
- rasa/builder/exceptions.py +12 -0
- rasa/builder/file_edits.py +175 -0
- rasa/builder/git_service.py +133 -17
- rasa/builder/job_helpers.py +4 -2
- rasa/builder/job_manager.py +5 -2
- rasa/builder/job_runner.py +61 -4
- rasa/builder/jobs.py +87 -16
- rasa/builder/logging_utils.py +4 -1
- rasa/builder/main.py +8 -3
- rasa/builder/models.py +300 -1
- rasa/builder/project_generator/project_generator.py +65 -22
- rasa/builder/service.py +1253 -235
- rasa/builder/skill_editing.py +299 -0
- rasa/builder/telemetry/langfuse_integration/copilot_v2_analysis_langfuse_telemetry.py +54 -25
- rasa/builder/telemetry/langfuse_integration/copilot_v2_langfuse_telemetry.py +53 -29
- rasa/builder/telemetry/langfuse_integration/langfuse_compat.py +28 -2
- rasa/builder/telemetry/langfuse_integration/mcp_lifecycle_langfuse_telemetry.py +5 -2
- rasa/builder/telemetry/langfuse_integration/message_classifier_langfuse_telemetry.py +6 -6
- rasa/builder/telemetry/langfuse_integration/plan_to_bot_langfuse_telemetry.py +152 -0
- rasa/builder/telemetry/langfuse_integration/planner_langfuse_telemetry.py +100 -0
- rasa/builder/telemetry/langfuse_integration/prompt_to_bot_langfuse_telemetry.py +75 -73
- rasa/builder/telemetry/langfuse_integration/welcome_langfuse_telemetry.py +5 -5
- rasa/builder/workspace.py +61 -1
- rasa/cli/coding_agents_init.py +227 -0
- rasa/cli/mantle_init.py +10 -160
- rasa/cli/project_templates/mantle/AGENTS.md +20 -11
- rasa/cli/project_templates/mantle/integrations.yml +3 -0
- rasa/cli/scaffold.py +35 -1
- rasa/cli/tools/init.py +119 -88
- rasa/cli/tools/skills.py +2 -23
- rasa/cli/tools/skills_data/mantle/mantle-configuring-agent/SKILL.md +3 -2
- rasa/cli/tools/skills_data/mantle/mantle-docs/SKILL.md +4 -3
- rasa/cli/tools/skills_data/mantle/mantle-simulating-evaluating/SKILL.md +19 -12
- rasa/cli/tools/utils.py +56 -1
- rasa/core/channels/inspector/dist/assets/{abnfDiagram-VCTEODGH-b11d5482.js → abnfDiagram-VCTEODGH-d1958068.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{arc-2eaeb096.js → arc-ee38fad9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/architecture-7GRP2DOG-90e64109.js +1 -0
- rasa/core/channels/inspector/dist/assets/{architectureDiagram-5GKGNRK7-e1d6e8db.js → architectureDiagram-5GKGNRK7-75f25ece.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{blockDiagram-I7D4REHJ-f4ca4a10.js → blockDiagram-I7D4REHJ-be4dfc82.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{c4Diagram-7LVT6UL2-4e259a14.js → c4Diagram-7LVT6UL2-6c68c7b2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/channel-d7154948.js +1 -0
- rasa/core/channels/inspector/dist/assets/{chunk-2Q5K7J3B-64f7a841.js → chunk-2Q5K7J3B-38bae51c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-5VM5RSS4-5dd9d41c.js → chunk-5VM5RSS4-39afa73b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-F27PBJKO-b72ffbcd.js → chunk-F27PBJKO-d8864d02.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-IMKFNOWR-6e9c3ee3.js → chunk-IMKFNOWR-cc51ad81.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-JWPE2WC7-418f4e49.js → chunk-JWPE2WC7-1fd37a6b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-POPQ4Y6H-acc3af14.js → chunk-POPQ4Y6H-9584d215.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-SHT3W25Y-5ab55c57.js → chunk-SHT3W25Y-28e9c55d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-SVP7TREG-a2e84a75.js → chunk-SVP7TREG-06ff7a0d.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-TICWLB2K-9129ba13.js → chunk-TICWLB2K-66344835.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{chunk-XXDRQBXY-b2c01a7c.js → chunk-XXDRQBXY-86512f44.js} +1 -1
- rasa/core/channels/inspector/dist/assets/classDiagram-ZZMXUADV-34c156a0.js +1 -0
- rasa/core/channels/inspector/dist/assets/classDiagram-v2-VYDZK3BY-34c156a0.js +1 -0
- rasa/core/channels/inspector/dist/assets/{cose-bilkent-JH36ORCC-40b1c40c.js → cose-bilkent-JH36ORCC-978e3c9c.js} +1 -1
- rasa/core/channels/inspector/dist/assets/cynefin-OW5HDTMX-220c7db2.js +1 -0
- rasa/core/channels/inspector/dist/assets/{cynefinDiagram-5FMLGOSQ-1f2d5a75.js → cynefinDiagram-5FMLGOSQ-b78bce1a.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{dagre-GXQ25YYZ-5916f5de.js → dagre-GXQ25YYZ-88aab4bf.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{diagram-S7CK7UJ4-515b2c7b.js → diagram-S7CK7UJ4-2c4a9d7e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{diagram-UQ7AKVKN-f04aba0e.js → diagram-UQ7AKVKN-b23ba5d2.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{diagram-VSXAHHWV-c2cdc700.js → diagram-VSXAHHWV-ab96361e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{diagram-VX7I27RA-ada5f312.js → diagram-VX7I27RA-431fb32b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{diagram-Z3DM3KII-7ad6ab4c.js → diagram-Z3DM3KII-12eeed50.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ebnfDiagram-PWID7BFC-b3ba9d61.js → ebnfDiagram-PWID7BFC-c979cb26.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{erDiagram-RLTQ6QDP-6b454736.js → erDiagram-RLTQ6QDP-f5eeb32b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/eventmodeling-NTZA5JFV-acd83c46.js +1 -0
- rasa/core/channels/inspector/dist/assets/flowDiagram-HODETNUW-24709173.js +1 -0
- rasa/core/channels/inspector/dist/assets/{ganttDiagram-EL5Y4UJY-ce96802c.js → ganttDiagram-EL5Y4UJY-d216bac9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/gitGraph-4MIJSDKK-7cacfd5c.js +1 -0
- rasa/core/channels/inspector/dist/assets/{gitGraphDiagram-WWUBYQGX-deb1e3db.js → gitGraphDiagram-WWUBYQGX-5420d961.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{index-99d3dee5.js → index-4caf5ccd.js} +249 -249
- rasa/core/channels/inspector/dist/assets/info-A6RAGUB7-bb61fd96.js +1 -0
- rasa/core/channels/inspector/dist/assets/{infoDiagram-27XIBGKW-9db77d2d.js → infoDiagram-27XIBGKW-180b31e5.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{ishikawaDiagram-5VMMS53U-d43e7233.js → ishikawaDiagram-5VMMS53U-865ede18.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{journeyDiagram-3NMN7TZE-7476bd50.js → journeyDiagram-3NMN7TZE-ab5c16a4.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{kanban-definition-UXKFOSKX-75c56573.js → kanban-definition-UXKFOSKX-60e32eae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{layout-6437a79a.js → layout-b6bb98e6.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{linear-cfc879a9.js → linear-c18a0949.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{mermaid-parser.core-2e0c3444.js → mermaid-parser.core-20cacf28.js} +2 -2
- rasa/core/channels/inspector/dist/assets/{mindmap-definition-YA3MSWOX-a12054ae.js → mindmap-definition-YA3MSWOX-5c31341b.js} +1 -1
- rasa/core/channels/inspector/dist/assets/packet-AYTQ26CC-796f482e.js +1 -0
- rasa/core/channels/inspector/dist/assets/{pegDiagram-XKGWAZYB-85975875.js → pegDiagram-XKGWAZYB-7d2d591e.js} +1 -1
- rasa/core/channels/inspector/dist/assets/pie-WAS4IAKB-28cdead8.js +1 -0
- rasa/core/channels/inspector/dist/assets/{pieDiagram-E7YTZNPT-02340dbe.js → pieDiagram-E7YTZNPT-2393742f.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{quadrantDiagram-AXDQQJYC-5bb1859c.js → quadrantDiagram-AXDQQJYC-c0848807.js} +1 -1
- rasa/core/channels/inspector/dist/assets/radar-RG4KPBEZ-acf328bd.js +1 -0
- rasa/core/channels/inspector/dist/assets/railroad-74A4TZTK-c0a5b202.js +1 -0
- rasa/core/channels/inspector/dist/assets/railroad-abnf-HS5TGJTU-ad9c4617.js +1 -0
- rasa/core/channels/inspector/dist/assets/railroad-ebnf-LZEXJU2U-23e5893b.js +1 -0
- rasa/core/channels/inspector/dist/assets/railroad-peg-WCYAUIDC-c0d968b1.js +1 -0
- rasa/core/channels/inspector/dist/assets/{railroadDiagram-O6MQD6OU-8efbb04a.js → railroadDiagram-O6MQD6OU-87d8dac1.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{requirementDiagram-BXWQKSXE-e8ca4a1f.js → requirementDiagram-BXWQKSXE-46904496.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sankeyDiagram-P5KCCOFB-bc485fba.js → sankeyDiagram-P5KCCOFB-f80f4f58.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sequenceDiagram-WJ2MYXX4-2c7676dd.js → sequenceDiagram-WJ2MYXX4-3c569c45.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{sizeCapture-INFHLROL-56ed2715.js → sizeCapture-INFHLROL-41b679ae.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{stateDiagram-D77RDMKH-fc904183.js → stateDiagram-D77RDMKH-ca621eb9.js} +1 -1
- rasa/core/channels/inspector/dist/assets/stateDiagram-v2-MP3YSRHH-63c65b13.js +1 -0
- rasa/core/channels/inspector/dist/assets/{swimlanes-42K2YHIH-bd338aed.js → swimlanes-42K2YHIH-5e5f8a34.js} +1 -1
- rasa/core/channels/inspector/dist/assets/swimlanesDiagram-VR7AAH4N-ce2e5a49.js +8 -0
- rasa/core/channels/inspector/dist/assets/{timeline-definition-24CTP7MA-c2b6cede.js → timeline-definition-24CTP7MA-510e1094.js} +1 -1
- rasa/core/channels/inspector/dist/assets/treeView-Q6P3EWNA-6d745140.js +1 -0
- rasa/core/channels/inspector/dist/assets/treemap-WGGIJYW6-6c85a610.js +1 -0
- rasa/core/channels/inspector/dist/assets/{vennDiagram-4TSXK5OY-97bf4e28.js → vennDiagram-4TSXK5OY-67d589b8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/wardley-WFR3VGLG-e9b2fc4e.js +1 -0
- rasa/core/channels/inspector/dist/assets/{wardleyDiagram-VM6X3IG4-387a3e02.js → wardleyDiagram-VM6X3IG4-c3766aa8.js} +1 -1
- rasa/core/channels/inspector/dist/assets/{xychartDiagram-S5SC5T6Z-c1eba0d6.js → xychartDiagram-S5SC5T6Z-c34778f7.js} +1 -1
- rasa/core/channels/inspector/dist/index.html +1 -1
- rasa/core/channels/inspector/package.json +1 -1
- rasa/core/channels/inspector/yarn.lock +4 -4
- rasa/core/channels/inspector-nextgen/dist/assets/index-DuPsMenp.js +1234 -0
- rasa/core/channels/inspector-nextgen/dist/index.html +1 -1
- rasa/core/channels/inspector-nextgen/e2e/actions/ui/inspector-shell.actions.ts +9 -6
- rasa/core/channels/inspector-nextgen/package.json +6 -6
- rasa/core/channels/inspector-nextgen/src/App.test.tsx +0 -9
- rasa/core/channels/inspector-nextgen/src/App.tsx +1 -3
- rasa/core/channels/inspector-nextgen/src/Icon/icons.ts +1 -0
- rasa/core/channels/inspector-nextgen/src/store/InspectorStore.ts +1 -1
- rasa/core/channels/inspector-nextgen/src/try-assistant/ChatHeader.test.tsx +37 -3
- rasa/core/channels/inspector-nextgen/src/try-assistant/ChatHeader.tsx +40 -17
- rasa/core/channels/inspector-nextgen/yarn.lock +200 -283
- rasa/core/channels/twilio.py +47 -0
- rasa/core/channels/twilio_utils.py +29 -0
- rasa/core/channels/voice_ready/twilio_voice.py +36 -0
- rasa/core/channels/voice_stream/asr/__init__.py +7 -0
- rasa/core/channels/voice_stream/asr/speechmatics.py +306 -0
- rasa/core/channels/voice_stream/audio_bytes.py +12 -0
- rasa/core/channels/voice_stream/tts/elevenlabs.py +105 -91
- rasa/core/channels/voice_stream/twilio_media_streams.py +51 -1
- rasa/core/config/available_endpoints.py +38 -0
- rasa/core/policies/flows/agent_executor.py +1 -1
- rasa/core/policies/flows/mcp_tool_executor.py +1 -1
- rasa/core/processor.py +81 -30
- rasa/dialogue_understanding/generator/multi_step/multi_step_llm_command_generator.py +3 -3
- rasa/dialogue_understanding/generator/single_step/single_step_based_llm_command_generator.py +1 -1
- rasa/e2e_test/constants.py +4 -0
- rasa/mantle/README-INTERNAL.md +9 -4
- rasa/mantle/config/builtin_tool_constraints.py +2 -0
- rasa/mantle/config/integrations.py +7 -3
- rasa/mantle/content/validation.py +3 -3
- rasa/mantle/llm/tool_schemas.py +2 -12
- rasa/mantle/memory/manager.py +63 -11
- rasa/mantle/orchestration/orchestrator.py +11 -4
- rasa/mantle/orchestration/skill_completion/completion_judge.py +1 -0
- rasa/mantle/orchestration/skill_executor.py +85 -17
- rasa/mantle/orchestration/tool_execution/invoker.py +13 -6
- rasa/mantle/processor.py +22 -2
- rasa/mantle/prompts/system_prompt.py +17 -3
- rasa/mantle/prompts/templates/__init__.py +2 -0
- rasa/mantle/prompts/templates/ack_reminder.jinja2 +8 -7
- rasa/mantle/prompts/templates/acknowledgement.jinja2 +37 -14
- rasa/mantle/prompts/templates/acknowledgement_examples.jinja2 +12 -0
- rasa/mantle/prompts/templates/current_turn.jinja2 +9 -0
- rasa/mantle/prompts/templates/lifecycle_tools.jinja2 +10 -4
- rasa/mantle/tools/decorator.py +11 -0
- rasa/mantle/tools/mcp_meta.py +44 -0
- rasa/mantle/tools/mcp_runtime.py +22 -5
- rasa/mantle/tools/validation.py +94 -6
- rasa/mantle/validation.py +4 -0
- rasa/model_manager/config.py +7 -0
- rasa/model_manager/model_api.py +250 -9
- rasa/privacy/privacy_filter.py +46 -18
- rasa/shared/constants.py +1 -0
- rasa/shared/utils/mcp/utils.py +12 -5
- rasa/telemetry.py +4 -1
- rasa/tracing/langfuse_config.py +74 -18
- rasa/tracing/langfuse_telemetry.py +296 -58
- rasa/utils/licensing.py +17 -2
- rasa/utils/log_utils.py +10 -0
- rasa/utils/secret_masking.py +152 -0
- rasa/utils/secret_redaction.py +22 -0
- rasa/version.py +1 -1
- {rasa_pro-3.22.0.dev1.dist-info → rasa_pro-3.22.0.dev2.dist-info}/METADATA +8 -8
- {rasa_pro-3.22.0.dev1.dist-info → rasa_pro-3.22.0.dev2.dist-info}/RECORD +223 -209
- rasa/core/channels/inspector/dist/assets/architecture-7GRP2DOG-7d8e9fb3.js +0 -1
- rasa/core/channels/inspector/dist/assets/channel-56fab013.js +0 -1
- rasa/core/channels/inspector/dist/assets/classDiagram-ZZMXUADV-7aa14c5a.js +0 -1
- rasa/core/channels/inspector/dist/assets/classDiagram-v2-VYDZK3BY-7aa14c5a.js +0 -1
- rasa/core/channels/inspector/dist/assets/cynefin-OW5HDTMX-9e58b572.js +0 -1
- rasa/core/channels/inspector/dist/assets/eventmodeling-NTZA5JFV-6e00461e.js +0 -1
- rasa/core/channels/inspector/dist/assets/flowDiagram-HODETNUW-1c7b5d0e.js +0 -1
- rasa/core/channels/inspector/dist/assets/gitGraph-4MIJSDKK-dd13bf80.js +0 -1
- rasa/core/channels/inspector/dist/assets/info-A6RAGUB7-a32342a8.js +0 -1
- rasa/core/channels/inspector/dist/assets/packet-AYTQ26CC-7582ca42.js +0 -1
- rasa/core/channels/inspector/dist/assets/pie-WAS4IAKB-7402b429.js +0 -1
- rasa/core/channels/inspector/dist/assets/radar-RG4KPBEZ-b8abfe08.js +0 -1
- rasa/core/channels/inspector/dist/assets/railroad-74A4TZTK-21a04f9c.js +0 -1
- rasa/core/channels/inspector/dist/assets/railroad-abnf-HS5TGJTU-30efc8b2.js +0 -1
- rasa/core/channels/inspector/dist/assets/railroad-ebnf-LZEXJU2U-d7b13030.js +0 -1
- rasa/core/channels/inspector/dist/assets/railroad-peg-WCYAUIDC-04a88000.js +0 -1
- rasa/core/channels/inspector/dist/assets/stateDiagram-v2-MP3YSRHH-1c0a1447.js +0 -1
- rasa/core/channels/inspector/dist/assets/swimlanesDiagram-VR7AAH4N-c0060217.js +0 -8
- rasa/core/channels/inspector/dist/assets/treeView-Q6P3EWNA-f8515f1e.js +0 -1
- rasa/core/channels/inspector/dist/assets/treemap-WGGIJYW6-6304ff34.js +0 -1
- rasa/core/channels/inspector/dist/assets/wardley-WFR3VGLG-e1c562e3.js +0 -1
- rasa/core/channels/inspector-nextgen/dist/assets/index-roixipDs.js +0 -1234
- rasa/core/channels/inspector-nextgen/src/SwitchButton.tsx +0 -30
- rasa/core/channels/inspector-nextgen/src/components/StandaloneHeader.test.tsx +0 -77
- rasa/core/channels/inspector-nextgen/src/components/StandaloneHeader.tsx +0 -31
- rasa/core/channels/inspector-nextgen/src/components/ViewControl.tsx +0 -40
- {rasa_pro-3.22.0.dev1.dist-info → rasa_pro-3.22.0.dev2.dist-info}/WHEEL +0 -0
- {rasa_pro-3.22.0.dev1.dist-info → rasa_pro-3.22.0.dev2.dist-info}/entry_points.txt +0 -0
- {rasa_pro-3.22.0.dev1.dist-info → rasa_pro-3.22.0.dev2.dist-info}/licenses/NOTICE +0 -0
|
@@ -28,6 +28,7 @@ except ImportError as exc:
|
|
|
28
28
|
from rasa.builder.agent_plan.models import AgentBuildPlan
|
|
29
29
|
from rasa.builder.copilot.pydantic_ai.config import PydanticAIConfig
|
|
30
30
|
from rasa.builder.copilot.pydantic_ai.file_tools import register_file_tools
|
|
31
|
+
from rasa.builder.copilot.pydantic_ai.instrumentation import build_instrumentation
|
|
31
32
|
from rasa.builder.copilot.pydantic_ai.prompt_loader import MANTLE_SYSTEM_PROMPT
|
|
32
33
|
from rasa.builder.copilot.pydantic_ai.run_context import CopilotRunContext
|
|
33
34
|
from rasa.builder.copilot.pydantic_ai.skills import (
|
|
@@ -95,7 +96,10 @@ def _build_agent(
|
|
|
95
96
|
output_type=str,
|
|
96
97
|
system_prompt=BUILDER_SYSTEM_PROMPT,
|
|
97
98
|
model_settings=ModelSettings(timeout=config.stream_event_timeout),
|
|
98
|
-
capabilities=
|
|
99
|
+
capabilities=[
|
|
100
|
+
build_instrumentation(),
|
|
101
|
+
*skill_capabilities(skills, defer_loading=False),
|
|
102
|
+
],
|
|
99
103
|
)
|
|
100
104
|
register_file_tools(agent)
|
|
101
105
|
register_skill_tools(agent)
|
|
@@ -101,6 +101,11 @@ class AgentBuildPlan(BaseModel):
|
|
|
101
101
|
BUILD_JOB_KIND = "build"
|
|
102
102
|
|
|
103
103
|
|
|
104
|
+
# The one plan kind in v1. The plan routes still send it, so Studio's contract
|
|
105
|
+
# keeps its field.
|
|
106
|
+
NEW_AGENT_PLAN_KIND = "new_agent"
|
|
107
|
+
|
|
108
|
+
|
|
104
109
|
class PlanStatus(str, Enum):
|
|
105
110
|
"""Lifecycle status of an agent build plan."""
|
|
106
111
|
|
|
@@ -130,5 +135,6 @@ class AgentPlanRecord(BaseModel):
|
|
|
130
135
|
prompt: str
|
|
131
136
|
latest_revision: PlanRevision
|
|
132
137
|
job_id: str | None = None
|
|
138
|
+
thread_id: str | None = None
|
|
133
139
|
created_at: datetime
|
|
134
140
|
updated_at: datetime
|
|
@@ -24,6 +24,11 @@ except ImportError as exc:
|
|
|
24
24
|
from rasa.builder.agent_plan.models import AgentBuildPlan
|
|
25
25
|
from rasa.builder.agent_plan.web_fetch import fetch_website_text
|
|
26
26
|
from rasa.builder.copilot.pydantic_ai.config import PydanticAIConfig
|
|
27
|
+
from rasa.builder.copilot.pydantic_ai.instrumentation import build_instrumentation
|
|
28
|
+
from rasa.builder.telemetry.langfuse_integration.langfuse_compat import observe
|
|
29
|
+
from rasa.builder.telemetry.langfuse_integration.planner_langfuse_telemetry import (
|
|
30
|
+
PlannerLangfuseTelemetry,
|
|
31
|
+
)
|
|
27
32
|
|
|
28
33
|
PLANNER_SYSTEM_PROMPT = """You are the Rasa Copilot planner for Mantle agents. From the user's description of an assistant, produce a build plan for a Mantle agent made of markdown skills.
|
|
29
34
|
|
|
@@ -84,6 +89,7 @@ def get_planner_agent() -> Agent[None, AgentBuildPlan]:
|
|
|
84
89
|
# capability. Using it directly avoids the deprecation warning and
|
|
85
90
|
# matches where the framework is headed.
|
|
86
91
|
capabilities=[
|
|
92
|
+
build_instrumentation(),
|
|
87
93
|
ProcessHistory(_compact_replayed_fetch_website_returns),
|
|
88
94
|
*web_search_capabilities,
|
|
89
95
|
],
|
|
@@ -187,19 +193,40 @@ def _compact_replayed_fetch_website_returns(
|
|
|
187
193
|
return compacted_messages
|
|
188
194
|
|
|
189
195
|
|
|
190
|
-
|
|
196
|
+
# Named after the agent run span this wraps, which used to be the trace root.
|
|
197
|
+
_PLANNER_SPAN_NAME = "copilot_v2_planner run"
|
|
198
|
+
|
|
199
|
+
|
|
200
|
+
# Arguments and return values are not captured: they carry the serialized
|
|
201
|
+
# message history. The input and output are set explicitly instead.
|
|
202
|
+
@observe(name=_PLANNER_SPAN_NAME, capture_input=False, capture_output=False)
|
|
203
|
+
async def create_plan(
|
|
204
|
+
prompt: str, plan_id: str, user_id: str | None = None
|
|
205
|
+
) -> tuple[AgentBuildPlan, bytes]:
|
|
191
206
|
"""Run the planner on a fresh prompt and return the plan plus its messages.
|
|
192
207
|
|
|
193
208
|
The returned bytes are the JSON-serialized ``all_messages()`` history,
|
|
194
209
|
stored so a later refinement can resume the same pydantic-ai conversation.
|
|
210
|
+
|
|
211
|
+
*plan_id* is the id the caller will persist the plan under. It is taken
|
|
212
|
+
up front, before the plan exists, so the drafting trace joins the same
|
|
213
|
+
Langfuse session as the plan's later refinements and build.
|
|
195
214
|
"""
|
|
196
|
-
|
|
215
|
+
with PlannerLangfuseTelemetry.trace_attributes(plan_id, user_id):
|
|
216
|
+
PlannerLangfuseTelemetry.update_create_plan_input(prompt)
|
|
217
|
+
result = await get_planner_agent().run(prompt)
|
|
218
|
+
PlannerLangfuseTelemetry.update_plan_output(result.output)
|
|
197
219
|
messages_json = ModelMessagesTypeAdapter.dump_json(result.all_messages())
|
|
198
220
|
return result.output, messages_json
|
|
199
221
|
|
|
200
222
|
|
|
223
|
+
@observe(name=_PLANNER_SPAN_NAME, capture_input=False, capture_output=False)
|
|
201
224
|
async def refine_plan(
|
|
202
|
-
feedback: str,
|
|
225
|
+
feedback: str,
|
|
226
|
+
messages_json: bytes | None,
|
|
227
|
+
current_plan: AgentBuildPlan,
|
|
228
|
+
plan_id: str,
|
|
229
|
+
user_id: str | None = None,
|
|
203
230
|
) -> tuple[AgentBuildPlan, bytes]:
|
|
204
231
|
"""Refine ``current_plan`` given user feedback.
|
|
205
232
|
|
|
@@ -207,14 +234,19 @@ async def refine_plan(
|
|
|
207
234
|
edit (PATCH) never went through the model, so ``messages_json`` alone may
|
|
208
235
|
be stale relative to what the user is actually looking at.
|
|
209
236
|
"""
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
237
|
+
with PlannerLangfuseTelemetry.trace_attributes(plan_id, user_id):
|
|
238
|
+
PlannerLangfuseTelemetry.update_refine_plan_input(feedback, current_plan)
|
|
239
|
+
message_history = (
|
|
240
|
+
ModelMessagesTypeAdapter.validate_json(messages_json)
|
|
241
|
+
if messages_json
|
|
242
|
+
else None
|
|
243
|
+
)
|
|
244
|
+
prompt = (
|
|
245
|
+
f"Current plan (may include direct user edits):\n"
|
|
246
|
+
f"{current_plan.model_dump_json()}\n\n"
|
|
247
|
+
f"Feedback: {feedback}"
|
|
248
|
+
)
|
|
249
|
+
result = await get_planner_agent().run(prompt, message_history=message_history)
|
|
250
|
+
PlannerLangfuseTelemetry.update_plan_output(result.output)
|
|
219
251
|
messages_json_out = ModelMessagesTypeAdapter.dump_json(result.all_messages())
|
|
220
252
|
return result.output, messages_json_out
|
rasa/builder/agent_plan/store.py
CHANGED
|
@@ -35,6 +35,19 @@ _ALLOWED_TRANSITIONS: dict[PlanStatus, set[PlanStatus]] = {
|
|
|
35
35
|
PlanStatus.DISCARDED: set(),
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
+
# `_build_record` reads the plan columns first, then the revision columns.
|
|
39
|
+
_PLAN_COLUMNS = (
|
|
40
|
+
"p.plan_id, p.agent_id, p.status, p.prompt, p.job_id, p.thread_id, "
|
|
41
|
+
"p.created_at, p.updated_at"
|
|
42
|
+
)
|
|
43
|
+
_REVISION_COLUMNS = "r.revision, r.source, r.plan_json, r.created_at"
|
|
44
|
+
|
|
45
|
+
# A plan in a thread stays open until it is built or discarded.
|
|
46
|
+
_OPEN_WITH_THREAD = (
|
|
47
|
+
f"status NOT IN ('{PlanStatus.BUILT.value}', "
|
|
48
|
+
f"'{PlanStatus.DISCARDED.value}') AND thread_id IS NOT NULL"
|
|
49
|
+
)
|
|
50
|
+
|
|
38
51
|
|
|
39
52
|
def _check_transition_allowed(current: PlanStatus, target: PlanStatus) -> None:
|
|
40
53
|
if target not in _ALLOWED_TRANSITIONS[current]:
|
|
@@ -51,6 +64,10 @@ class PlanNotFoundError(KeyError):
|
|
|
51
64
|
"""Raised when a plan id has no record in the store."""
|
|
52
65
|
|
|
53
66
|
|
|
67
|
+
class OpenPlanExistsError(ValueError):
|
|
68
|
+
"""Raised when the thread or the agent already has an open plan."""
|
|
69
|
+
|
|
70
|
+
|
|
54
71
|
class SQLitePlanStore:
|
|
55
72
|
"""SQLite-backed agent plan store.
|
|
56
73
|
|
|
@@ -62,6 +79,7 @@ class SQLitePlanStore:
|
|
|
62
79
|
|
|
63
80
|
_PLANS_TABLE = "agent_plans"
|
|
64
81
|
_REVISIONS_TABLE = "agent_plan_revisions"
|
|
82
|
+
_PLAN_THREADS_TABLE = "agent_plan_threads"
|
|
65
83
|
|
|
66
84
|
def __init__(self, db_path: str) -> None:
|
|
67
85
|
if not db_path or not db_path.strip():
|
|
@@ -86,6 +104,7 @@ class SQLitePlanStore:
|
|
|
86
104
|
prompt TEXT NOT NULL,
|
|
87
105
|
messages_json TEXT,
|
|
88
106
|
job_id TEXT,
|
|
107
|
+
thread_id TEXT,
|
|
89
108
|
created_at TEXT NOT NULL,
|
|
90
109
|
updated_at TEXT NOT NULL
|
|
91
110
|
)
|
|
@@ -103,22 +122,49 @@ class SQLitePlanStore:
|
|
|
103
122
|
)
|
|
104
123
|
"""
|
|
105
124
|
)
|
|
106
|
-
|
|
125
|
+
conn.execute(
|
|
126
|
+
f"""
|
|
127
|
+
CREATE TABLE IF NOT EXISTS {self._PLAN_THREADS_TABLE} (
|
|
128
|
+
agent_id TEXT NOT NULL,
|
|
129
|
+
user_id TEXT NOT NULL,
|
|
130
|
+
thread_id TEXT NOT NULL,
|
|
131
|
+
PRIMARY KEY (agent_id, user_id)
|
|
132
|
+
)
|
|
133
|
+
"""
|
|
134
|
+
)
|
|
135
|
+
# Older databases do not have these columns yet.
|
|
107
136
|
columns = {
|
|
108
137
|
row[1]
|
|
109
138
|
for row in conn.execute(f"PRAGMA table_info({self._PLANS_TABLE})")
|
|
110
139
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
140
|
+
for column, definition in (
|
|
141
|
+
("agent_id", "TEXT NOT NULL DEFAULT ''"),
|
|
142
|
+
("thread_id", "TEXT"),
|
|
143
|
+
):
|
|
144
|
+
if column not in columns:
|
|
145
|
+
conn.execute(
|
|
146
|
+
f"ALTER TABLE {self._PLANS_TABLE} "
|
|
147
|
+
f"ADD COLUMN {column} {definition}"
|
|
148
|
+
)
|
|
149
|
+
conn.execute(
|
|
150
|
+
f"CREATE UNIQUE INDEX IF NOT EXISTS agent_plans_one_open_per_thread "
|
|
151
|
+
f"ON {self._PLANS_TABLE} (thread_id) WHERE {_OPEN_WITH_THREAD}"
|
|
152
|
+
)
|
|
153
|
+
conn.execute(
|
|
154
|
+
f"CREATE UNIQUE INDEX IF NOT EXISTS agent_plans_one_open_per_agent "
|
|
155
|
+
f"ON {self._PLANS_TABLE} (agent_id) WHERE {_OPEN_WITH_THREAD}"
|
|
156
|
+
)
|
|
116
157
|
conn.commit()
|
|
117
158
|
|
|
118
159
|
# ── synchronous helpers (run via asyncio.to_thread) ────────────────────
|
|
119
160
|
|
|
120
161
|
def _create_plan(
|
|
121
|
-
self,
|
|
162
|
+
self,
|
|
163
|
+
plan_id: str,
|
|
164
|
+
agent_id: str,
|
|
165
|
+
prompt: str,
|
|
166
|
+
plan: AgentBuildPlan,
|
|
167
|
+
thread_id: str | None,
|
|
122
168
|
) -> AgentPlanRecord:
|
|
123
169
|
now = _now_iso()
|
|
124
170
|
with open_sqlite_connection(self._db_path) as conn:
|
|
@@ -127,10 +173,18 @@ class SQLitePlanStore:
|
|
|
127
173
|
f"""
|
|
128
174
|
INSERT INTO {self._PLANS_TABLE}
|
|
129
175
|
(plan_id, agent_id, status, prompt, messages_json,
|
|
130
|
-
job_id, created_at, updated_at)
|
|
131
|
-
VALUES (?, ?, ?, ?, NULL, NULL, ?, ?)
|
|
176
|
+
job_id, thread_id, created_at, updated_at)
|
|
177
|
+
VALUES (?, ?, ?, ?, NULL, NULL, ?, ?, ?)
|
|
132
178
|
""",
|
|
133
|
-
(
|
|
179
|
+
(
|
|
180
|
+
plan_id,
|
|
181
|
+
agent_id,
|
|
182
|
+
PlanStatus.DRAFT.value,
|
|
183
|
+
prompt,
|
|
184
|
+
thread_id,
|
|
185
|
+
now,
|
|
186
|
+
now,
|
|
187
|
+
),
|
|
134
188
|
)
|
|
135
189
|
conn.execute(
|
|
136
190
|
f"""
|
|
@@ -141,58 +195,54 @@ class SQLitePlanStore:
|
|
|
141
195
|
(plan_id, plan.model_dump_json(), now),
|
|
142
196
|
)
|
|
143
197
|
conn.commit()
|
|
198
|
+
except sqlite3.IntegrityError as exc:
|
|
199
|
+
conn.rollback()
|
|
200
|
+
if thread_id is None or not self._open_plan_exists(
|
|
201
|
+
conn, agent_id, thread_id
|
|
202
|
+
):
|
|
203
|
+
raise
|
|
204
|
+
raise OpenPlanExistsError(
|
|
205
|
+
"The thread or the agent already has an open plan."
|
|
206
|
+
) from exc
|
|
144
207
|
except Exception:
|
|
145
208
|
conn.rollback()
|
|
146
209
|
raise
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
210
|
+
record = self._get_plan(plan_id)
|
|
211
|
+
if record is None:
|
|
212
|
+
raise PlanNotFoundError(plan_id)
|
|
213
|
+
return record
|
|
214
|
+
|
|
215
|
+
def _has_open_plan(self, agent_id: str, thread_id: str) -> bool:
|
|
216
|
+
with open_sqlite_connection(self._db_path) as conn:
|
|
217
|
+
return self._open_plan_exists(conn, agent_id, thread_id)
|
|
218
|
+
|
|
219
|
+
def _open_plan_exists(
|
|
220
|
+
self, conn: sqlite3.Connection, agent_id: str, thread_id: str
|
|
221
|
+
) -> bool:
|
|
222
|
+
row = conn.execute(
|
|
223
|
+
f"SELECT 1 FROM {self._PLANS_TABLE} WHERE {_OPEN_WITH_THREAD} "
|
|
224
|
+
f"AND (thread_id = ? OR agent_id = ?) LIMIT 1",
|
|
225
|
+
(thread_id, agent_id),
|
|
226
|
+
).fetchone()
|
|
227
|
+
return row is not None
|
|
159
228
|
|
|
160
229
|
def _get_plan(self, plan_id: str) -> AgentPlanRecord | None:
|
|
161
230
|
with open_sqlite_connection(self._db_path) as conn:
|
|
162
231
|
plan_row = conn.execute(
|
|
163
|
-
f""
|
|
164
|
-
|
|
165
|
-
FROM {self._PLANS_TABLE} WHERE plan_id = ?
|
|
166
|
-
""",
|
|
232
|
+
f"SELECT {_PLAN_COLUMNS} FROM {self._PLANS_TABLE} p "
|
|
233
|
+
f"WHERE p.plan_id = ?",
|
|
167
234
|
(plan_id,),
|
|
168
235
|
).fetchone()
|
|
169
236
|
if plan_row is None:
|
|
170
237
|
return None
|
|
171
238
|
revision_row = conn.execute(
|
|
172
|
-
f""
|
|
173
|
-
|
|
174
|
-
FROM {self._REVISIONS_TABLE}
|
|
175
|
-
WHERE plan_id = ? ORDER BY revision DESC LIMIT 1
|
|
176
|
-
""",
|
|
239
|
+
f"SELECT {_REVISION_COLUMNS} FROM {self._REVISIONS_TABLE} r "
|
|
240
|
+
f"WHERE r.plan_id = ? ORDER BY r.revision DESC LIMIT 1",
|
|
177
241
|
(plan_id,),
|
|
178
242
|
).fetchone()
|
|
179
243
|
if revision_row is None:
|
|
180
244
|
return None
|
|
181
|
-
|
|
182
|
-
revision, source, plan_json, revision_created_at = revision_row
|
|
183
|
-
return _build_record(
|
|
184
|
-
plan_id,
|
|
185
|
-
agent_id,
|
|
186
|
-
status,
|
|
187
|
-
prompt,
|
|
188
|
-
job_id,
|
|
189
|
-
created_at,
|
|
190
|
-
updated_at,
|
|
191
|
-
revision,
|
|
192
|
-
source,
|
|
193
|
-
AgentBuildPlan.model_validate_json(plan_json),
|
|
194
|
-
revision_created_at,
|
|
195
|
-
)
|
|
245
|
+
return _build_record(*plan_row, *revision_row)
|
|
196
246
|
|
|
197
247
|
def _get_revision(self, plan_id: str, revision: int) -> PlanRevision | None:
|
|
198
248
|
with open_sqlite_connection(self._db_path) as conn:
|
|
@@ -218,9 +268,7 @@ class SQLitePlanStore:
|
|
|
218
268
|
with open_sqlite_connection(self._db_path) as conn:
|
|
219
269
|
rows = conn.execute(
|
|
220
270
|
f"""
|
|
221
|
-
SELECT
|
|
222
|
-
p.updated_at, r.revision, r.source, r.plan_json,
|
|
223
|
-
r.created_at
|
|
271
|
+
SELECT {_PLAN_COLUMNS}, {_REVISION_COLUMNS}
|
|
224
272
|
FROM {self._PLANS_TABLE} p
|
|
225
273
|
JOIN {self._REVISIONS_TABLE} r ON r.plan_id = p.plan_id
|
|
226
274
|
WHERE p.agent_id = ?
|
|
@@ -233,33 +281,7 @@ class SQLitePlanStore:
|
|
|
233
281
|
""",
|
|
234
282
|
(agent_id, PlanStatus.DISCARDED.value),
|
|
235
283
|
).fetchall()
|
|
236
|
-
return [
|
|
237
|
-
_build_record(
|
|
238
|
-
plan_id,
|
|
239
|
-
agent_id,
|
|
240
|
-
status,
|
|
241
|
-
prompt,
|
|
242
|
-
job_id,
|
|
243
|
-
created_at,
|
|
244
|
-
updated_at,
|
|
245
|
-
revision,
|
|
246
|
-
source,
|
|
247
|
-
AgentBuildPlan.model_validate_json(plan_json),
|
|
248
|
-
revision_created_at,
|
|
249
|
-
)
|
|
250
|
-
for (
|
|
251
|
-
plan_id,
|
|
252
|
-
status,
|
|
253
|
-
prompt,
|
|
254
|
-
job_id,
|
|
255
|
-
created_at,
|
|
256
|
-
updated_at,
|
|
257
|
-
revision,
|
|
258
|
-
source,
|
|
259
|
-
plan_json,
|
|
260
|
-
revision_created_at,
|
|
261
|
-
) in rows
|
|
262
|
-
]
|
|
284
|
+
return [_build_record(*row) for row in rows]
|
|
263
285
|
|
|
264
286
|
def _add_revision(
|
|
265
287
|
self, plan_id: str, plan: AgentBuildPlan, source: str
|
|
@@ -383,16 +405,59 @@ class SQLitePlanStore:
|
|
|
383
405
|
raise PlanNotFoundError(plan_id)
|
|
384
406
|
return row[0].encode("utf-8") if row[0] is not None else None
|
|
385
407
|
|
|
408
|
+
def _set_plan_thread(self, agent_id: str, user_id: str, thread_id: str) -> None:
|
|
409
|
+
with open_sqlite_connection(self._db_path) as conn:
|
|
410
|
+
conn.execute(
|
|
411
|
+
f"INSERT INTO {self._PLAN_THREADS_TABLE} "
|
|
412
|
+
f"(agent_id, user_id, thread_id) VALUES (?, ?, ?) "
|
|
413
|
+
f"ON CONFLICT (agent_id, user_id) "
|
|
414
|
+
f"DO UPDATE SET thread_id = excluded.thread_id",
|
|
415
|
+
(agent_id, user_id, thread_id),
|
|
416
|
+
)
|
|
417
|
+
conn.commit()
|
|
418
|
+
|
|
419
|
+
def _get_plan_thread(self, agent_id: str, user_id: str) -> str | None:
|
|
420
|
+
with open_sqlite_connection(self._db_path) as conn:
|
|
421
|
+
row = conn.execute(
|
|
422
|
+
f"SELECT thread_id FROM {self._PLAN_THREADS_TABLE} "
|
|
423
|
+
f"WHERE agent_id = ? AND user_id = ?",
|
|
424
|
+
(agent_id, user_id),
|
|
425
|
+
).fetchone()
|
|
426
|
+
return row[0] if row else None
|
|
427
|
+
|
|
428
|
+
def _clear_plan_thread(self, agent_id: str, user_id: str, thread_id: str) -> None:
|
|
429
|
+
with open_sqlite_connection(self._db_path) as conn:
|
|
430
|
+
conn.execute(
|
|
431
|
+
f"DELETE FROM {self._PLAN_THREADS_TABLE} "
|
|
432
|
+
f"WHERE agent_id = ? AND user_id = ? AND thread_id = ?",
|
|
433
|
+
(agent_id, user_id, thread_id),
|
|
434
|
+
)
|
|
435
|
+
conn.commit()
|
|
436
|
+
|
|
386
437
|
# ── async API ────────────────────────────────────────────────────────
|
|
387
438
|
|
|
388
439
|
async def create_plan(
|
|
389
|
-
self,
|
|
440
|
+
self,
|
|
441
|
+
plan_id: str,
|
|
442
|
+
agent_id: str,
|
|
443
|
+
prompt: str,
|
|
444
|
+
plan: AgentBuildPlan,
|
|
445
|
+
thread_id: str | None = None,
|
|
390
446
|
) -> AgentPlanRecord:
|
|
391
|
-
"""Create a new plan, writing revision 1 with source ``"planner"``.
|
|
447
|
+
"""Create a new plan, writing revision 1 with source ``"planner"``.
|
|
448
|
+
|
|
449
|
+
Raises:
|
|
450
|
+
OpenPlanExistsError: If ``thread_id`` already has an open plan, or
|
|
451
|
+
the agent already has an open new-agent plan in a thread.
|
|
452
|
+
"""
|
|
392
453
|
return await asyncio.to_thread(
|
|
393
|
-
self._create_plan, plan_id, agent_id, prompt, plan
|
|
454
|
+
self._create_plan, plan_id, agent_id, prompt, plan, thread_id
|
|
394
455
|
)
|
|
395
456
|
|
|
457
|
+
async def has_open_plan(self, agent_id: str, thread_id: str) -> bool:
|
|
458
|
+
"""Return whether the thread or the agent already has an open plan."""
|
|
459
|
+
return await asyncio.to_thread(self._has_open_plan, agent_id, thread_id)
|
|
460
|
+
|
|
396
461
|
async def get_plan(self, plan_id: str) -> AgentPlanRecord | None:
|
|
397
462
|
"""Return the plan joined with its latest revision, or ``None``."""
|
|
398
463
|
return await asyncio.to_thread(self._get_plan, plan_id)
|
|
@@ -430,6 +495,22 @@ class SQLitePlanStore:
|
|
|
430
495
|
"""Return the stored serialized message history, or ``None``."""
|
|
431
496
|
return await asyncio.to_thread(self._get_messages, plan_id)
|
|
432
497
|
|
|
498
|
+
async def set_plan_thread(
|
|
499
|
+
self, agent_id: str, user_id: str, thread_id: str
|
|
500
|
+
) -> None:
|
|
501
|
+
"""Record ``thread_id`` as the user's plan thread for the agent."""
|
|
502
|
+
await asyncio.to_thread(self._set_plan_thread, agent_id, user_id, thread_id)
|
|
503
|
+
|
|
504
|
+
async def get_plan_thread(self, agent_id: str, user_id: str) -> str | None:
|
|
505
|
+
"""Return the user's plan thread for the agent, or ``None``."""
|
|
506
|
+
return await asyncio.to_thread(self._get_plan_thread, agent_id, user_id)
|
|
507
|
+
|
|
508
|
+
async def clear_plan_thread(
|
|
509
|
+
self, agent_id: str, user_id: str, thread_id: str
|
|
510
|
+
) -> None:
|
|
511
|
+
"""Forget the user's plan thread, but only if it is still ``thread_id``."""
|
|
512
|
+
await asyncio.to_thread(self._clear_plan_thread, agent_id, user_id, thread_id)
|
|
513
|
+
|
|
433
514
|
|
|
434
515
|
def new_plan_id() -> str:
|
|
435
516
|
"""Return a fresh random plan id."""
|
|
@@ -458,12 +539,13 @@ def _build_record(
|
|
|
458
539
|
status: str,
|
|
459
540
|
prompt: str,
|
|
460
541
|
job_id: str | None,
|
|
542
|
+
thread_id: str | None,
|
|
461
543
|
created_at: str,
|
|
462
544
|
updated_at: str,
|
|
463
545
|
revision: int,
|
|
464
546
|
source: str,
|
|
465
|
-
|
|
466
|
-
revision_created_at: str
|
|
547
|
+
plan_json: str,
|
|
548
|
+
revision_created_at: str,
|
|
467
549
|
) -> AgentPlanRecord:
|
|
468
550
|
return AgentPlanRecord(
|
|
469
551
|
plan_id=plan_id,
|
|
@@ -473,10 +555,11 @@ def _build_record(
|
|
|
473
555
|
latest_revision=PlanRevision(
|
|
474
556
|
revision=revision,
|
|
475
557
|
source=source,
|
|
476
|
-
plan=
|
|
477
|
-
created_at=datetime.fromisoformat(revision_created_at
|
|
558
|
+
plan=AgentBuildPlan.model_validate_json(plan_json),
|
|
559
|
+
created_at=datetime.fromisoformat(revision_created_at),
|
|
478
560
|
),
|
|
479
561
|
job_id=job_id,
|
|
562
|
+
thread_id=thread_id,
|
|
480
563
|
created_at=datetime.fromisoformat(created_at),
|
|
481
564
|
updated_at=datetime.fromisoformat(updated_at),
|
|
482
565
|
)
|