agentengine-sdk-python 0.8.4__py3-none-any.whl → 0.8.5__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.
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.5.dist-info}/METADATA +6 -3
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.5.dist-info}/RECORD +591 -365
- ksadk/_build_provenance.json +1 -1
- ksadk/_process.py +83 -0
- ksadk/_str_enum.py +17 -0
- ksadk/a2ui/core.py +3 -3
- ksadk/api/client.py +6 -0
- ksadk/builders/code_builder.py +38 -12
- ksadk/builders/framework_requirements.py +20 -2
- ksadk/cli/__init__.py +36 -0
- ksadk/cli/cmd_config.py +4 -4
- ksadk/cli/cmd_create.py +12 -12
- ksadk/cli/cmd_hermes.py +24 -2
- ksadk/cli/cmd_invoke.py +28 -5
- ksadk/cli/cmd_openclaw.py +26 -1
- ksadk/cli/cmd_plugin.py +70 -12
- ksadk/cli/cmd_studio.py +64 -16
- ksadk/cli/openclaw_env.py +1 -1
- ksadk/cli/resource_common.py +26 -0
- ksadk/codex/client.py +3 -2
- ksadk/configs/__init__.py +1 -1
- ksadk/configs/env_registry.py +125 -31
- ksadk/configs/env_registry_studio.py +86 -0
- ksadk/configs/global_config.py +1 -1
- ksadk/configs/settings.py +3 -3
- ksadk/connector/__init__.py +17 -0
- ksadk/connector/channel.py +477 -0
- ksadk/context_engine/capabilities.py +52 -4
- ksadk/conversations/attachment_storage.py +10 -3
- ksadk/conversations/attachments.py +16 -5
- ksadk/conversations/message_projection.py +23 -32
- ksadk/conversations/normalize.py +28 -10
- ksadk/conversations/runtime_baseline.py +37 -0
- ksadk/conversations/runtime_invocation.py +17 -4
- ksadk/conversations/runtime_observability.py +39 -10
- ksadk/conversations/runtime_payloads.py +8 -0
- ksadk/conversations/runtime_persistence.py +105 -9
- ksadk/conversations/runtime_preparation.py +13 -7
- ksadk/conversations/runtime_stream_events.py +29 -35
- ksadk/conversations/runtime_streaming.py +8 -0
- ksadk/events/adapters/_codex_items.py +16 -8
- ksadk/events/adapters/_langgraph_support.py +34 -0
- ksadk/events/session_event.py +2 -2
- ksadk/harness/__init__.py +14 -0
- ksadk/harness/app.py +11 -0
- ksadk/harness/artifact_store.py +213 -0
- ksadk/harness/capabilities.py +115 -0
- ksadk/harness/capability_runtime.py +237 -0
- ksadk/harness/closure_contract.py +92 -0
- ksadk/harness/compaction_record.py +122 -0
- ksadk/harness/compiler.py +284 -0
- ksadk/harness/conformance/__init__.py +33 -0
- ksadk/harness/conformance/contract.py +506 -0
- ksadk/harness/conformance/fixtures.py +102 -0
- ksadk/harness/context_engine.py +403 -0
- ksadk/harness/context_maintenance.py +259 -0
- ksadk/harness/context_manifest.py +188 -0
- ksadk/harness/context_tuning.py +168 -0
- ksadk/harness/draft_runtime.py +322 -0
- ksadk/harness/engine/__init__.py +40 -0
- ksadk/harness/engine/base.py +122 -0
- ksadk/harness/engine/budgets.py +108 -0
- ksadk/harness/engine/capability_declarations.py +59 -0
- ksadk/harness/engine/completion_guard.py +42 -0
- ksadk/harness/engine/context_pipeline.py +579 -0
- ksadk/harness/engine/graph_builder.py +859 -0
- ksadk/harness/engine/langgraph.py +931 -0
- ksadk/harness/engine/mcp_disclosure.py +750 -0
- ksadk/harness/engine/policy_runtime.py +70 -0
- ksadk/harness/engine/postgres_checkpointer.py +63 -0
- ksadk/harness/engine/run_control_bridge.py +80 -0
- ksadk/harness/engine/run_types.py +88 -0
- ksadk/harness/engine/skill_disclosure.py +189 -0
- ksadk/harness/engine/spans.py +41 -0
- ksadk/harness/engine/subagents.py +343 -0
- ksadk/harness/engine/thread_ids.py +112 -0
- ksadk/harness/engine/tool_dispatch.py +144 -0
- ksadk/harness/event_tree.py +212 -0
- ksadk/harness/events.py +461 -0
- ksadk/harness/execution_policy.py +94 -0
- ksadk/harness/insights.py +210 -0
- ksadk/harness/lifecycle.py +578 -0
- ksadk/harness/lifecycle_conformance.py +233 -0
- ksadk/harness/lifecycle_local_plane.py +104 -0
- ksadk/harness/loop/__init__.py +44 -0
- ksadk/harness/loop/reason.py +454 -0
- ksadk/harness/loop/tools.py +762 -0
- ksadk/harness/managed_runtime.py +884 -0
- ksadk/harness/mcp_matrix.py +474 -0
- ksadk/harness/mcp_runtime.py +471 -0
- ksadk/harness/memory_consolidation.py +157 -0
- ksadk/harness/memory_loop.py +156 -0
- ksadk/harness/memory_runtime.py +541 -0
- ksadk/harness/metrics.py +90 -0
- ksadk/harness/model_capability.py +253 -0
- ksadk/harness/model_provider.py +220 -0
- ksadk/harness/observability/__init__.py +29 -0
- ksadk/harness/observability/inspection.py +528 -0
- ksadk/harness/observability/metrics.py +167 -0
- ksadk/harness/observability/otel_exporter.py +218 -0
- ksadk/harness/prompt_cache.py +70 -0
- ksadk/harness/public_activity.py +154 -0
- ksadk/harness/readiness.py +249 -0
- ksadk/harness/reasoner.py +466 -13
- ksadk/harness/release_readiness.py +140 -0
- ksadk/harness/resource_ref.py +69 -0
- ksadk/harness/run_control.py +668 -0
- ksadk/harness/runtime.py +146 -111
- ksadk/harness/runtime_capabilities.py +158 -0
- ksadk/harness/runtime_server.py +514 -0
- ksadk/harness/sandbox_adapters.py +739 -0
- ksadk/harness/sandbox_backend.py +530 -0
- ksadk/harness/sandbox_conformance.py +288 -0
- ksadk/harness/sandbox_lease.py +77 -0
- ksadk/harness/sandbox_lease_conformance.py +259 -0
- ksadk/harness/sandbox_matrix.py +170 -0
- ksadk/harness/sandbox_reconciliation.py +140 -0
- ksadk/harness/sandbox_recovery.py +586 -0
- ksadk/harness/sandbox_recovery_conformance.py +246 -0
- ksadk/harness/session_store.py +243 -0
- ksadk/harness/skill_composition.py +212 -0
- ksadk/harness/skill_feedback.py +123 -0
- ksadk/harness/skill_matrix.py +233 -0
- ksadk/harness/skill_runtime.py +259 -0
- ksadk/harness/spec.py +332 -0
- ksadk/harness/state.py +153 -0
- ksadk/harness/strategies.py +149 -0
- ksadk/harness/subagent.py +253 -0
- ksadk/harness/tool_policy.py +131 -0
- ksadk/harness/tool_receipts.py +96 -0
- ksadk/harness/tool_reliability.py +81 -0
- ksadk/harness/user_errors.py +69 -0
- ksadk/harness/working_context.py +81 -0
- ksadk/harness/working_context_patch.py +99 -0
- ksadk/identity/resolver.py +18 -0
- ksadk/interaction/__init__.py +1 -1
- ksadk/interaction/ledger.py +1 -1
- ksadk/interaction/provider.py +1 -1
- ksadk/interaction/providers/__init__.py +3 -1
- ksadk/interaction/providers/adk.py +1 -1
- ksadk/interaction/providers/codex.py +1 -1
- ksadk/interaction/providers/harness.py +50 -0
- ksadk/interaction/providers/langgraph.py +1 -1
- ksadk/kernel/__init__.py +10 -0
- ksadk/kernel/approval_presentation.py +91 -0
- ksadk/kernel/authorization.py +1 -1
- ksadk/kernel/bootstrap.py +86 -102
- ksadk/kernel/contract_fingerprints.py +1 -1
- ksadk/kernel/contracts.py +5 -0
- ksadk/kernel/control.py +32 -1
- ksadk/kernel/execution_grants.py +221 -0
- ksadk/kernel/execution_grants_memory.py +133 -0
- ksadk/kernel/execution_grants_postgres.py +217 -0
- ksadk/kernel/execution_grants_sqlite.py +209 -0
- ksadk/kernel/ingress.py +27 -27
- ksadk/kernel/mapping.py +1 -1
- ksadk/kernel/memory_store.py +24 -11
- ksadk/kernel/postgres_store.py +63 -33
- ksadk/kernel/recovery.py +78 -14
- ksadk/kernel/sql/001_agent_kernel.sql +23 -0
- ksadk/kernel/sqlite_store.py +304 -25
- ksadk/kernel/state.py +2 -3
- ksadk/kernel/store.py +69 -2
- ksadk/kernel/worker.py +79 -41
- ksadk/kernel/worker_history.py +72 -0
- ksadk/kernel/worker_identity.py +47 -0
- ksadk/memory/coordinator.py +22 -6
- ksadk/memory/extraction.py +40 -1
- ksadk/memory/models.py +77 -1
- ksadk/memory/provider_resolver.py +5 -0
- ksadk/memory/providers/local_postgres.py +200 -0
- ksadk/memory/providers/local_sqlite.py +42 -3
- ksadk/memory/retrieval.py +189 -0
- ksadk/memory/store_adapter.py +150 -0
- ksadk/model_policy.py +2 -2
- ksadk/model_proxy/detect.py +254 -0
- ksadk/model_proxy/server.py +4 -2
- ksadk/model_proxy/transform.py +40 -2
- ksadk/plugins/__init__.py +1 -1
- ksadk/plugins/bridges/dsh.py +11 -0
- ksadk/plugins/builtins.py +40 -2
- ksadk/plugins/companion_artifacts.py +83 -0
- ksadk/plugins/companions.py +368 -0
- ksadk/plugins/contracts.py +1 -1
- ksadk/plugins/dsh_channels.py +156 -0
- ksadk/plugins/dsh_home.py +140 -0
- ksadk/plugins/dsh_teams.py +105 -0
- ksadk/plugins/dsh_toolchain.py +101 -19
- ksadk/plugins/execution_host.py +99 -0
- ksadk/plugins/providers/bundles/dsh-channels-client/client.js +19 -0
- ksadk/plugins/providers/bundles/dsh-channels-client/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-channels-client/index.mjs +7 -0
- ksadk/plugins/providers/bundles/dsh-channels-client/package.json +12 -0
- ksadk/plugins/providers/bundles/dsh-knowledge/package.json +1 -1
- ksadk/plugins/providers/bundles/dsh-memory/package.json +1 -1
- ksadk/plugins/providers/bundles/dsh-skill-center/package.json +1 -1
- ksadk/plugins/providers/bundles/dsh-teams-client/client.js +29 -0
- ksadk/plugins/providers/bundles/dsh-teams-client/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-teams-client/index.mjs +11 -0
- ksadk/plugins/providers/bundles/dsh-teams-client/package.json +35 -0
- ksadk/plugins/providers/bundles/dsh-teams-leader-policy/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-teams-leader-policy/index.mjs +13 -0
- ksadk/plugins/providers/bundles/dsh-teams-leader-policy/package.json +27 -0
- ksadk/plugins/providers/bundles/dsh-teams-profile/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-teams-profile/index.mjs +12 -0
- ksadk/plugins/providers/bundles/dsh-teams-profile/package.json +26 -0
- ksadk/plugins/providers/bundles/dsh-teams-router/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-teams-router/index.mjs +16 -0
- ksadk/plugins/providers/bundles/dsh-teams-router/package.json +27 -0
- ksadk/plugins/providers/bundles/dsh-teams-tasks/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-teams-tasks/index.mjs +16 -0
- ksadk/plugins/providers/bundles/dsh-teams-tasks/package.json +27 -0
- ksadk/plugins/providers/bundles/dsh-teams-tools/cordis.patch.yml +3 -0
- ksadk/plugins/providers/bundles/dsh-teams-tools/index.mjs +25 -0
- ksadk/plugins/providers/bundles/dsh-teams-tools/package.json +29 -0
- ksadk/plugins/providers/bundles/dsh-teams-tools/tools.json +235 -0
- ksadk/plugins/providers/bundles/ksadk-codex/index.mjs +1 -1
- ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/index.mjs +51 -1
- ksadk/plugins/providers/bundles/ksadk-dsh-capability-host/package.json +2 -2
- ksadk/plugins/providers/bundles/ksadk-dsh-companion-host/client.mjs +133 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-companion-host/index.mjs +14 -0
- ksadk/plugins/providers/bundles/ksadk-dsh-studio/client.js +27 -4
- ksadk/plugins/providers/bundles/ksadk-dsh-studio/index.mjs +9 -5
- ksadk/plugins/providers/bundles/ksadk-harness/index.mjs +1 -1
- ksadk/plugins/providers/codex.py +10 -2
- ksadk/plugins/providers/dsh_capabilities.py +61 -0
- ksadk/plugins/providers/harness.py +181 -33
- ksadk/plugins/providers/harness_delegation.py +593 -0
- ksadk/plugins/providers/harness_managed.py +456 -0
- ksadk/plugins/providers/harness_tools.py +326 -0
- ksadk/plugins/providers/shipped_dsh.py +4 -1
- ksadk/plugins/subagent_providers/codex.py +28 -6
- ksadk/plugins/teams/__init__.py +5 -0
- ksadk/plugins/teams/api.py +405 -0
- ksadk/plugins/teams/application.py +680 -0
- ksadk/plugins/teams/artifacts.py +60 -0
- ksadk/plugins/teams/context.py +96 -0
- ksadk/plugins/teams/contracts.py +136 -0
- ksadk/plugins/teams/domain.py +1427 -0
- ksadk/plugins/teams/domain_values.py +24 -0
- ksadk/plugins/teams/errors.py +13 -0
- ksadk/plugins/teams/migration.py +311 -0
- ksadk/plugins/teams/migration_cli.py +322 -0
- ksadk/plugins/teams/postgres_store.py +138 -0
- ksadk/plugins/teams/runtime.py +777 -0
- ksadk/plugins/teams/source_projection.py +84 -0
- ksadk/plugins/teams/store.py +311 -0
- ksadk/plugins/teams/task_decisions.py +423 -0
- ksadk/plugins/teams/transport.py +91 -0
- ksadk/plugins/teams/workspaces.py +255 -0
- ksadk/runners/_langgraph_runner_streams.py +121 -45
- ksadk/runners/_langgraph_state_reader.py +106 -0
- ksadk/runners/_session_identity.py +285 -0
- ksadk/runners/adk_runner.py +25 -60
- ksadk/runners/langgraph_runner.py +128 -111
- ksadk/runners/patch_langchain.py +47 -0
- ksadk/runners/usage_accumulator.py +11 -3
- ksadk/runtime/_runner_adapter/stream_mapping.py +52 -2
- ksadk/runtime/conversation_execution.py +25 -1
- ksadk/runtime/executor.py +9 -1
- ksadk/runtime/factory.py +36 -1
- ksadk/runtime/preprocessing.py +11 -3
- ksadk/runtime/runner_adapter.py +38 -9
- ksadk/runtime/skill_eval_result.py +36 -0
- ksadk/runtime/timing.py +46 -0
- ksadk/runtime/usage.py +49 -18
- ksadk/runtime_context.py +103 -1
- ksadk/sandbox/backends/e2b.py +245 -23
- ksadk/sandbox/backends/local_process.py +63 -39
- ksadk/sandbox/base.py +62 -1
- ksadk/sandbox/diagnostics.py +82 -0
- ksadk/sandbox/local_controls.py +746 -0
- ksadk/sandbox/local_launcher.py +90 -0
- ksadk/scheduler/dispatcher.py +1 -1
- ksadk/server/invocation_identity.py +118 -0
- ksadk/server/routes/common.py +32 -3
- ksadk/server/routes/control.py +64 -9
- ksadk/server/routes/dependencies.py +2 -1
- ksadk/server/routes/kernel_ingress.py +9 -1
- ksadk/server/routes/misc.py +233 -25
- ksadk/server/routes/models.py +3 -3
- ksadk/server/routes/openai_compat.py +76 -13
- ksadk/server/routes/run.py +106 -35
- ksadk/server/routes/sessions.py +244 -68
- ksadk/server/routes/workspace.py +130 -21
- ksadk/server/static/assets/{ArtifactsPanel-CGbWlMNh.js → ArtifactsPanel-C1YoaKhx.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-b4C7upmO.js → CodeBlock-DHuAWfr5.js} +10 -7
- ksadk/server/static/assets/MathMessageMarkdown-cvdrBwYr.js +8 -0
- ksadk/server/static/assets/{MermaidBlock-BEBN4Ksz.js → MermaidBlock-DeBkbJvI.js} +9 -9
- ksadk/server/static/assets/{NativeTerminalPanel-zvL-WpAn.js → NativeTerminalPanel-oJj44_sV.js} +1 -1
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-BYafW7Za.js → abnfDiagram-VCTEODGH-Dhfv25o2.js} +1 -1
- ksadk/server/static/assets/{arc-bTohInsS.js → arc-C35w-pn1.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-BCsa26zi.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-Ch5Lbzsi.js → architectureDiagram-5GKGNRK7-FoMY_u6D.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-kqF4MDOG.js → blockDiagram-NRAW4CY4-zD4Rt7oE.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-8uSRIODv.js → c4Diagram-UCG6FXSJ-BCtGGkhN.js} +1 -1
- ksadk/server/static/assets/channel-_KDifNys.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-HdVkJ9F0.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-DkhehZDr.js → chunk-5VM5RSS4-C2Ms13_k.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-BdXhtPe9.js → chunk-F27PBJKO-BoTj-qgx.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-DPTpvpwi.js → chunk-G27WJ6UU-DOMyyjHH.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-Pqoh38el.js → chunk-JWPE2WC7-DbJJqDli.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-DeU00qC-.js → chunk-LCL6LL3I-CLuRCt_W.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-CzxScFkr.js → chunk-POPQ4Y6H-D0Dz847e.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-DpqMx-ux.js → chunk-RHFEMEQ7-BWSRzEcd.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-C6t0SypQ.js → chunk-SVP7TREG-CPoHqkCY.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-DVaeafZk.js → chunk-XXDRQBXY-Bx1jS-X-.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-BVCW3ZqZ.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-BVCW3ZqZ.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-Bf9D3tzJ.js → cose-bilkent-JH36ORCC-LzyWm4m0.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-CNXjFctL.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-B9cY3iTz.js → cynefinDiagram-5FMLGOSQ-BlW_bHED.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-CSwlx3CB.js → dagre-3AP2YEHR-Bu_S86_i.js} +1 -1
- ksadk/server/static/assets/{dagre-UBpgon5q.js → dagre-B7nCawed.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-C9akhN9a.js → diagram-S7CK7UJ4-W_Zow2Km.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-CgedhTPI.js → diagram-UQ7AKVKN-CLIKAHON.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-Cjucz5BY.js → diagram-VSXAHHWV-Dv6_QAlN.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-Dd4Vleyn.js → diagram-VX7I27RA-BWAWRDtZ.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-CZ2jGtYW.js → diagram-Z3DM3KII-XA_rWMss.js} +1 -1
- ksadk/server/static/assets/dist-0X_j2Rcc.js +1 -0
- ksadk/server/static/assets/{dist-DiixqL0J.js → dist-1nXCdsej.js} +1 -1
- ksadk/server/static/assets/{dist-BIr4DSRq.js → dist-2vL2sAdF.js} +1 -1
- ksadk/server/static/assets/{dist-D_ctSS2i.js → dist-B3bA05-e.js} +1 -1
- ksadk/server/static/assets/{dist-ClYUxfeK.js → dist-BLpRy_Yx.js} +1 -1
- ksadk/server/static/assets/{dist-QfkEHOlb.js → dist-BO_UwatH.js} +1 -1
- ksadk/server/static/assets/{dist-B3FR1SKK.js → dist-BdNFAney.js} +1 -1
- ksadk/server/static/assets/{dist-BnaTiyzN.js → dist-C0J5_3qM.js} +1 -1
- ksadk/server/static/assets/{dist-Bj730Ib4.js → dist-CGt_UGeO.js} +1 -1
- ksadk/server/static/assets/{dist-CFzsn6BG.js → dist-CIRMvUM4.js} +1 -1
- ksadk/server/static/assets/{dist-BgV_owcB.js → dist-CIpWk_5f.js} +1 -1
- ksadk/server/static/assets/{dist-C5_ZAZsG.js → dist-CPyieXEf.js} +1 -1
- ksadk/server/static/assets/{dist-btbmmX5O.js → dist-D-92S-Fd.js} +1 -1
- ksadk/server/static/assets/{dist-fBO2v5Kt.js → dist-DNKuMzWc.js} +1 -1
- ksadk/server/static/assets/{dist-ufY3F5p6.js → dist-DWfdmz9s.js} +2 -2
- ksadk/server/static/assets/{dist-DVCOWtha.js → dist-DppE_r-D.js} +1 -1
- ksadk/server/static/assets/{dist-C1NMAY5a.js → dist-DyG6Ya-z.js} +1 -1
- ksadk/server/static/assets/{dist-CB9iJrvg.js → dist-M-SrdhhZ.js} +1 -1
- ksadk/server/static/assets/{dist-DvFK7p5S.js → dist-mqD5TZup.js} +1 -1
- ksadk/server/static/assets/{dist-Cf125P_m.js → dist-n3n6t_FO.js} +1 -1
- ksadk/server/static/assets/{dist-DFD6Qa6T.js → dist-qe8xjesy.js} +1 -1
- ksadk/server/static/assets/{dist-DoVSwoDb.js → dist-t6MzE0jU.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-Ci8NqqZu.js → ebnfDiagram-PWID7BFC-BfCzF1Xi.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-CCIOhLZG.js → erDiagram-SSCWMZ5O-Dpz9_0zn.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-B5-8RH9c.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-BppFxEKw.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-Cp_r9Hb6.js → ganttDiagram-EL5Y4UJY-DDaG1f4_.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-B-AhYj4C.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-Dlhc8Wr8.js → gitGraphDiagram-WWUBYQGX-DcxzRwYC.js} +1 -1
- ksadk/server/static/assets/index-BMd2mucF.css +2 -0
- ksadk/server/static/assets/index-D5qyyhTH.js +244 -0
- ksadk/server/static/assets/info-A6RAGUB7-0uiKrC35.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-CO0rRTRA.js → infoDiagram-RXCK75RN-CYMdn6lQ.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-CHiaedSS.js → ishikawaDiagram-5VMMS53U-CLHFAD6c.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL-CHcCIB09.js → journeyDiagram-EYS64GPL-BHSKQGAl.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-CJ_ebBZf.js → kanban-definition-3QL26DDD-D5W3tjTT.js} +1 -1
- ksadk/server/static/assets/{katex-B4weu383.js → katex-mtjOi4KM.js} +1 -1
- ksadk/server/static/assets/{linear-V-MgYHW1.js → linear-BETqsxE_.js} +1 -1
- ksadk/server/static/assets/{mermaid-parser.core-CBijEX_c.js → mermaid-parser.core-DPWrvs90.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-Bc-pQvpp.js → mindmap-definition-FBJOCRG2-CJG2mfBP.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-BVTmZ_cw.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-D7genGLl.js → pegDiagram-XKGWAZYB-GjAPNaqn.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-DyfxBU7V.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-Bxj32zwD.js → pieDiagram-E7YTZNPT-ToIewrqr.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-BURv2mGh.js → quadrantDiagram-AXDQQJYC-4d78KiEY.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-FFontjL2.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-D0Uidzen.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-BOo_9T2h.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-D6-BjW7Z.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-CXx__yMm.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-CCsh3avW.js → railroadDiagram-O6MQD6OU-DKzx4xfv.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-_FRRBKEd.js → requirementDiagram-EFPCY7ZU-CJYljxQS.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-C-gr2o9M.js → sankeyDiagram-P5KCCOFB-DLU2fV1w.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-D97NmfKg.js → sequenceDiagram-WJ2MYXX4-CVqysrA9.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-DjrPC5FX.js → sizeCapture-X5ZJPWSS-BUxfmTHc.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-DzMNg1hh.js → stateDiagram-HBIQ2CUA-CNFgYI9E.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BXAFScz8.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-Cssf_CsU.js → swimlanes-XN3QIQJK-B6qCMe8N.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-uIQ2lJKH.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-BWTHzyS1.js → timeline-definition-24CTP7MA-CMD3x_U_.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-CK5GgucZ.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-Bq1u1SpG.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-BSKgJsmR.js → vennDiagram-4TSXK5OY-BqtUqvXM.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-QAt06uEz.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-eflHNoaZ.js → wardleyDiagram-VM6X3IG4-B5KfDjI-.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-eYqrQ-v4.js → xychartDiagram-S5SC5T6Z-BaUlSZrn.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/server/terminal_sessions.py +34 -2
- ksadk/sessions/invocation_identity.py +235 -0
- ksadk/skills/__init__.py +26 -0
- ksadk/skills/events.py +464 -0
- ksadk/skills/manifest_cache.py +263 -0
- ksadk/skills/mcp_server/__init__.py +0 -0
- ksadk/skills/mcp_server/_registry.py +33 -0
- ksadk/skills/mcp_server/_routing.py +26 -0
- ksadk/skills/mcp_server/_workspace_files.py +160 -0
- ksadk/skills/mcp_server/register.py +415 -0
- ksadk/skills/mcp_server/server.py +218 -0
- ksadk/skills/models.py +11 -0
- ksadk/skills/observability.py +132 -0
- ksadk/skills/package_store.py +75 -2
- ksadk/skills/runtime/agent.py +38 -5
- ksadk/skills/runtime/artifacts.py +87 -0
- ksadk/skills/runtime/backends/e2b.py +393 -52
- ksadk/skills/runtime/backends/local.py +621 -119
- ksadk/skills/runtime/base.py +78 -7
- ksadk/skills/runtime/executor.py +266 -1
- ksadk/skills/runtime/loader.py +108 -3
- ksadk/skills/runtime/request.py +18 -0
- ksadk/skills/tool_defs.py +108 -3
- ksadk/studio/api.py +592 -57
- ksadk/studio/api_contracts.py +8 -2
- ksadk/studio/api_plugin_routes.py +39 -12
- ksadk/studio/api_resource_connections.py +79 -41
- ksadk/studio/authoring.py +12 -6
- ksadk/studio/authoring_coordinator.py +4 -2
- ksadk/studio/builder.py +12 -0
- ksadk/studio/capabilities.py +23 -6
- ksadk/studio/channel_connections.py +333 -0
- ksadk/studio/cloud.py +30 -10
- ksadk/studio/cloud_shared_web.py +75 -2
- ksadk/studio/codex_agent_service.py +2 -2
- ksadk/studio/codex_builder.py +1 -1
- ksadk/studio/codex_run.py +6 -1
- ksadk/studio/compiler.py +10 -0
- ksadk/studio/configuration.py +182 -0
- ksadk/studio/contracts.py +33 -5
- ksadk/studio/dsh_application.py +135 -25
- ksadk/studio/dsh_capability_service.py +287 -20
- ksadk/studio/dsh_lifecycle.py +58 -0
- ksadk/studio/dsh_provider_registration.py +55 -16
- ksadk/studio/entry.py +53 -0
- ksadk/studio/event_store.py +36 -5
- ksadk/studio/execution_host.py +525 -0
- ksadk/studio/framework_run.py +32 -10
- ksadk/studio/hosted_kernel.py +1 -1
- ksadk/studio/kernel_registry.py +418 -0
- ksadk/studio/kernel_sqlite_migration.py +181 -0
- ksadk/studio/model_client.py +1178 -64
- ksadk/studio/model_profile_service.py +26 -11
- ksadk/studio/native_documents.py +172 -0
- ksadk/studio/plugin_composition.py +13 -2
- ksadk/studio/plugin_kernel_adapter.py +15 -0
- ksadk/studio/plugin_lifecycle.py +80 -0
- ksadk/studio/plugin_runtime.py +230 -17
- ksadk/studio/provider_recovery.py +59 -0
- ksadk/studio/recovery_page.py +70 -0
- ksadk/studio/resource_authority.py +59 -32
- ksadk/studio/resource_catalog.py +6 -0
- ksadk/studio/run_activity.py +895 -0
- ksadk/studio/run_documents.py +127 -0
- ksadk/studio/run_service.py +329 -33
- ksadk/studio/runtime_catalog.py +53 -10
- ksadk/studio/runtime_source.py +1 -1
- ksadk/studio/scheduler_runtime.py +32 -289
- ksadk/studio/service.py +398 -103
- ksadk/studio/shared_web.py +149 -36
- ksadk/studio/static/assets/ChannelsPage-D_PGmKVq.js +8 -0
- ksadk/studio/static/assets/CodeBlock-DMIf4h33-UIqo-BPW.js +44 -0
- ksadk/studio/static/assets/ExecutionTree-v3HexvPo-Bk8wzGSy.js +1 -0
- ksadk/studio/static/assets/MathMessageMarkdown-BesSeCYl-OhNwH4K9.js +8 -0
- ksadk/studio/static/assets/MermaidBlock-H_0qzQDf-BdXtxug_.js +11 -0
- ksadk/studio/static/assets/MessageMarkdown-CwMTvgFj-g0I-I4dD.js +59 -0
- ksadk/studio/static/assets/PrismRenderer-5pK6tUdb.js +3 -0
- ksadk/studio/static/assets/TeamsPage-DqX4HWKQ.js +3 -0
- ksadk/studio/static/assets/abnfDiagram-VCTEODGH-Bnb1O3tA.js +1 -0
- ksadk/studio/static/assets/architecture-7GRP2DOG-BMOPAkUC.js +1 -0
- ksadk/studio/static/assets/architectureDiagram-5GKGNRK7-5Zn1gqJv.js +36 -0
- ksadk/studio/static/assets/{blockDiagram-I7D4REHJ-CFmPl1de.js → blockDiagram-I7D4REHJ-CLB4L11u.js} +6 -6
- ksadk/studio/static/assets/{c4Diagram-7LVT6UL2-BRrGu8qt.js → c4Diagram-7LVT6UL2-BOma_Z_F.js} +7 -7
- ksadk/studio/static/assets/channel-r8itPEik.js +1 -0
- ksadk/studio/static/assets/chunk-2E4U76K2-BFf_huql.js +2 -0
- ksadk/studio/static/assets/chunk-2ZTRR5NV-C2qZJila.js +2 -0
- ksadk/studio/static/assets/chunk-3Z5EZCMW-DMniOlPd.js +1 -0
- ksadk/studio/static/assets/{chunk-4HAMMTFA-D220vUtq.js → chunk-4HAMMTFA-DVtDP4rm.js} +7 -7
- ksadk/studio/static/assets/chunk-5V3GS4D5-i-ZDOEnP.js +1 -0
- ksadk/studio/static/assets/chunk-6AZGARVD-BB6FqMl-.js +1 -0
- ksadk/studio/static/assets/chunk-6EIED4P4-DdUJkP0f.js +1 -0
- ksadk/studio/static/assets/chunk-6K3QC6MW-CqVsVn-y.js +1 -0
- ksadk/studio/static/assets/chunk-6TQVIW2G-DKlLbNIP.js +1 -0
- ksadk/studio/static/assets/chunk-747NJXEK-BFkZPlab.js +2 -0
- ksadk/studio/static/assets/chunk-75Z2AOVW-BZNhM4vB.js +2 -0
- ksadk/studio/static/assets/chunk-CLGD4ZFX-D-GTtyKs.js +1 -0
- ksadk/studio/static/assets/{chunk-DU6HZSFF-C4DtVpCu.js → chunk-DU6HZSFF-CpEZCUgg.js} +1 -1
- ksadk/studio/static/assets/chunk-F27PBJKO-D7pvKf0C.js +1 -0
- ksadk/studio/static/assets/{chunk-GMAD6QVW-DiQA-u2N.js → chunk-GMAD6QVW-DE_8H717.js} +6 -6
- ksadk/studio/static/assets/chunk-GVQU2GXP-BfEB0lNv.js +1 -0
- ksadk/studio/static/assets/chunk-I5DQTOEV-Hm2LfiYI.js +1 -0
- ksadk/studio/static/assets/chunk-ICYGCRZG-749o-pGJ.js +1 -0
- ksadk/studio/static/assets/chunk-IH6LHLGP-CC6I9F3i.js +1 -0
- ksadk/studio/static/assets/{chunk-IMKFNOWR-BSlbjT_b.js → chunk-IMKFNOWR-D38axYOR.js} +5 -5
- ksadk/studio/static/assets/chunk-KI3K4JFJ-Rma-0k_M.js +1 -0
- ksadk/studio/static/assets/chunk-L3NEJ4N5-Dq5xn7aL.js +1 -0
- ksadk/studio/static/assets/chunk-LNGE3PJU-DWpGwHrW.js +34 -0
- ksadk/studio/static/assets/{chunk-OSK3NFVY-M2m6G3j4.js → chunk-OSK3NFVY-DiCQjx9b.js} +5 -5
- ksadk/studio/static/assets/chunk-OUJLGHUK-D0j2JRSg.js +2 -0
- ksadk/studio/static/assets/{chunk-P2QGCYS3-DezaQxiK.js → chunk-P2QGCYS3-VdhKmfYq.js} +1 -1
- ksadk/studio/static/assets/chunk-POPQ4Y6H-C1_rzO5M.js +1 -0
- ksadk/studio/static/assets/chunk-PWAF6VOD-B45HvflI.js +1 -0
- ksadk/studio/static/assets/{chunk-SHT3W25Y-DAyIVp5H.js → chunk-SHT3W25Y-DsCFnRVE.js} +9 -9
- ksadk/studio/static/assets/{chunk-SVP7TREG-DulomOrS.js → chunk-SVP7TREG-DljApgRX.js} +1 -1
- ksadk/studio/static/assets/{chunk-TICWLB2K-bHJYoflj.js → chunk-TICWLB2K-DWqRtyqa.js} +6 -6
- ksadk/studio/static/assets/chunk-TLUHSLCS-DUeGgnD5.js +2 -0
- ksadk/studio/static/assets/chunk-UY3FDG6J-CnmaAkG5.js +1 -0
- ksadk/studio/static/assets/chunk-XHIXRSVI-BFQ6B8BE.js +1 -0
- ksadk/studio/static/assets/chunk-XXDRQBXY-DqAYeljN.js +1 -0
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-DjeMNJmu.js +1 -0
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-DjeMNJmu.js +1 -0
- ksadk/studio/static/assets/clsx-DB0hHKMi.js +1 -0
- ksadk/studio/static/assets/cose-bilkent-JH36ORCC-om8AY0Mc.js +1 -0
- ksadk/studio/static/assets/createLucideIcon-DR0LGTP5.js +1 -0
- ksadk/studio/static/assets/cynefin-OW5HDTMX-7tP7QfM3.js +1 -0
- ksadk/studio/static/assets/cynefinDiagram-5FMLGOSQ-6BrmK52S.js +62 -0
- ksadk/studio/static/assets/dagre-GXQ25YYZ-buZBRlwz.js +4 -0
- ksadk/studio/static/assets/{diagram-S7CK7UJ4-0BZ98mya.js → diagram-S7CK7UJ4-C6aH78c4.js} +3 -3
- ksadk/studio/static/assets/diagram-UQ7AKVKN-DY_tQ6C_.js +41 -0
- ksadk/studio/static/assets/diagram-VSXAHHWV-DX9p5cQT.js +3 -0
- ksadk/studio/static/assets/diagram-VX7I27RA-DB2WSH8X.js +24 -0
- ksadk/studio/static/assets/diagram-Z3DM3KII-Ce1BJwHE.js +24 -0
- ksadk/studio/static/assets/ebnfDiagram-PWID7BFC-Daukxwqf.js +1 -0
- ksadk/studio/static/assets/{erDiagram-RLTQ6QDP-DLGry2Ap.js → erDiagram-RLTQ6QDP-CGthTMmJ.js} +6 -6
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-BR2FzK4R.js +1 -0
- ksadk/studio/static/assets/flowDiagram-HODETNUW-CZ1tEenp.js +1 -0
- ksadk/studio/static/assets/ganttDiagram-EL5Y4UJY-BfoAZW9X.js +292 -0
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-DYlXv_yJ.js +1 -0
- ksadk/studio/static/assets/gitGraphDiagram-WWUBYQGX-S985OIJF.js +106 -0
- ksadk/studio/static/assets/iconfont-4HN3C9Pg.woff2 +0 -0
- ksadk/studio/static/assets/index-CfEnms6Y.css +2 -0
- ksadk/studio/static/assets/index-Dp61rOWZ.js +0 -0
- ksadk/studio/static/assets/index.dom-BQenBtFm.js +1 -0
- ksadk/studio/static/assets/info-A6RAGUB7-BlU-8_xu.js +1 -0
- ksadk/studio/static/assets/infoDiagram-27XIBGKW-CO3W8tFn.js +2 -0
- ksadk/studio/static/assets/{ishikawaDiagram-5VMMS53U-CljI2wyf.js → ishikawaDiagram-5VMMS53U-BUGEl8cO.js} +2 -2
- ksadk/studio/static/assets/{journeyDiagram-3NMN7TZE-D50Fo2sL.js → journeyDiagram-3NMN7TZE-Ch2ZYxvr.js} +6 -6
- ksadk/studio/static/assets/{kanban-definition-UXKFOSKX-DimfOTam.js → kanban-definition-UXKFOSKX-Da-Fp4vC.js} +3 -3
- ksadk/studio/static/assets/kingsoft-cloud-BOcLiQ3e.ico +0 -0
- ksadk/studio/static/assets/{line-CX5BOOUP.js → line-BDaeq300.js} +1 -1
- ksadk/studio/static/assets/linear-DmucvK78.js +1 -0
- ksadk/studio/static/assets/mermaid-parser.core-Cj5mYdBi.js +4 -0
- ksadk/studio/static/assets/{mindmap-definition-YA3MSWOX-Bizzqy5R.js → mindmap-definition-YA3MSWOX-CvlsVQ38.js} +1 -1
- ksadk/studio/static/assets/packet-AYTQ26CC-BSJEH9Lb.js +1 -0
- ksadk/studio/static/assets/pegDiagram-XKGWAZYB-BuHuNgT5.js +1 -0
- ksadk/studio/static/assets/pie-WAS4IAKB-qxv01Y8W.js +1 -0
- ksadk/studio/static/assets/{pieDiagram-E7YTZNPT-B9mrFSDF.js → pieDiagram-E7YTZNPT-DlrWiSOv.js} +1 -1
- ksadk/studio/static/assets/preload-helper-CO68xz6u.js +1 -0
- ksadk/studio/static/assets/presentation-yYw7xK60-BmcZriri.js +1 -0
- ksadk/studio/static/assets/{quadrantDiagram-AXDQQJYC-NzUfCbMR.js → quadrantDiagram-AXDQQJYC-BA3hpUZM.js} +6 -6
- ksadk/studio/static/assets/radar-RG4KPBEZ-B6h6pWOs.js +1 -0
- ksadk/studio/static/assets/railroad-74A4TZTK-CGtTWdGc.js +1 -0
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-Cq7y22IA.js +1 -0
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-V0aQVv9m.js +1 -0
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-BQiIsX_p.js +1 -0
- ksadk/studio/static/assets/railroadDiagram-O6MQD6OU-BxpAazym.js +1 -0
- ksadk/studio/static/assets/{requirementDiagram-BXWQKSXE-BF3d103U.js → requirementDiagram-BXWQKSXE-E-Ge0FcV.js} +1 -1
- ksadk/studio/static/assets/sankeyDiagram-P5KCCOFB-CA6YKhQ3.js +40 -0
- ksadk/studio/static/assets/{sequenceDiagram-WJ2MYXX4-Dh4wZtUm.js → sequenceDiagram-WJ2MYXX4-CcElXGg4.js} +9 -9
- ksadk/studio/static/assets/src-B6xuSHsQ.js +1 -0
- ksadk/studio/static/assets/stateDiagram-D77RDMKH-DdXZOFqY.js +1 -0
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-CJbOM-QK.js +1 -0
- ksadk/studio/static/assets/swimlanes-42K2YHIH-NtgEEHLY.js +1 -0
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-D-AVlW8B.js +8 -0
- ksadk/studio/static/assets/{timeline-definition-24CTP7MA-DxmSSjRB.js → timeline-definition-24CTP7MA-CIuYhNy3.js} +7 -7
- ksadk/studio/static/assets/treeView-Q6P3EWNA-BTTYcvrF.js +1 -0
- ksadk/studio/static/assets/treemap-WGGIJYW6-Cg7tyfH8.js +1 -0
- ksadk/studio/static/assets/vennDiagram-4TSXK5OY-7HbApbrv.js +34 -0
- ksadk/studio/static/assets/wardley-WFR3VGLG-C6N1rULY.js +1 -0
- ksadk/studio/static/assets/{wardleyDiagram-VM6X3IG4-Ba1AOWoe.js → wardleyDiagram-VM6X3IG4-CMJiaedy.js} +1 -1
- ksadk/studio/static/assets/{xychartDiagram-S5SC5T6Z-Cr5pt5Y-.js → xychartDiagram-S5SC5T6Z-BdgtMvW2.js} +6 -6
- ksadk/studio/static/index.html +8 -2
- ksadk/studio/teams_catalog.py +133 -0
- ksadk/studio/teams_installation.py +214 -0
- ksadk/studio/teams_node.py +545 -0
- ksadk/studio/teams_node_runner.py +69 -0
- ksadk/studio/teams_remote.py +274 -0
- ksadk/studio/templates.py +40 -19
- ksadk/studio/validator.py +13 -0
- ksadk/studio/workspace.py +19 -4
- ksadk/studio/workspace_plugins.py +136 -0
- ksadk/studio/workspace_registry.py +286 -0
- ksadk/toolsets/__init__.py +11 -0
- ksadk/toolsets/skills.py +446 -378
- ksadk/toolsets/workspace.py +3 -3
- ksadk/toolsets/workspace_identity.py +15 -0
- ksadk/version.py +1 -1
- ksadk_runtime_common/memory_backend/providers/lancedb.py +56 -2
- ksadk_runtime_common/schemas/memory_backend_manifest.schema.json +148 -148
- ksadk_runtime_common/workspace_files/router.py +26 -13
- ksadk/server/static/assets/MathMessageMarkdown-DbdW5A4_.js +0 -8
- ksadk/server/static/assets/architecture-7GRP2DOG-BW5UtSnx.js +0 -1
- ksadk/server/static/assets/channel-CF5Up3hQ.js +0 -1
- ksadk/server/static/assets/chunk-2Q5K7J3B-KkXX47WI.js +0 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-Cz81acRQ.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-Cz81acRQ.js +0 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-DVWs8a2t.js +0 -1
- ksadk/server/static/assets/dist-B2_CVgKv.js +0 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-CQqR2hg3.js +0 -1
- ksadk/server/static/assets/flowDiagram-A5DVABFB-DDRRbGPm.js +0 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-fgWEf7UD.js +0 -1
- ksadk/server/static/assets/index-DcTML1Up.css +0 -2
- ksadk/server/static/assets/index-Dh2XHqPK.js +0 -244
- ksadk/server/static/assets/info-A6RAGUB7-BUecLTdt.js +0 -1
- ksadk/server/static/assets/packet-AYTQ26CC-BeW-btFv.js +0 -1
- ksadk/server/static/assets/pie-WAS4IAKB-X0xh4SaT.js +0 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-DzRMSqjd.js +0 -1
- ksadk/server/static/assets/railroad-74A4TZTK-Cc44icX-.js +0 -1
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-D6S4BdV-.js +0 -1
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-vD3aVE2o.js +0 -1
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-CYbW_b4T.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-BIcjKFhF.js +0 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-tq3K3Ybl.js +0 -8
- ksadk/server/static/assets/treeView-Q6P3EWNA-DBXt3GdU.js +0 -1
- ksadk/server/static/assets/treemap-WGGIJYW6-DrCy4E_l.js +0 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-CefhOliM.js +0 -1
- ksadk/studio/static/assets/CodeBlock-DCUUY0PL-BLjA7kbS.js +0 -41
- ksadk/studio/static/assets/MathMessageMarkdown-CBcDrAw--CUYIXwgI.js +0 -8
- ksadk/studio/static/assets/MermaidBlock-DBFTztfQ-BTYKWEbD.js +0 -44
- ksadk/studio/static/assets/PrismRenderer-wiXRHURw.js +0 -3
- ksadk/studio/static/assets/abnfDiagram-VCTEODGH-CLETGjKq.js +0 -1
- ksadk/studio/static/assets/architecture-7GRP2DOG-hXMiO_AU.js +0 -1
- ksadk/studio/static/assets/architectureDiagram-5GKGNRK7-B5EQysk6.js +0 -36
- ksadk/studio/static/assets/channel-BqO-gtEw.js +0 -1
- ksadk/studio/static/assets/chunk-75Z2AOVW-C8lLv_qc.js +0 -2
- ksadk/studio/static/assets/chunk-F27PBJKO-Cpw14SNG.js +0 -1
- ksadk/studio/static/assets/chunk-GVQU2GXP-DUdNBUCi.js +0 -1
- ksadk/studio/static/assets/chunk-L3NEJ4N5-Db8Ab22W.js +0 -1
- ksadk/studio/static/assets/chunk-POPQ4Y6H-DOpufJ3t.js +0 -1
- ksadk/studio/static/assets/chunk-PWAF6VOD-CfLb1gSc.js +0 -1
- ksadk/studio/static/assets/chunk-XXDRQBXY-7PcdR2B1.js +0 -1
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-D_bW8JjA.js +0 -1
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-D_bW8JjA.js +0 -1
- ksadk/studio/static/assets/cose-bilkent-JH36ORCC-snL88wkX.js +0 -1
- ksadk/studio/static/assets/cynefin-OW5HDTMX-Bd1YhRo1.js +0 -1
- ksadk/studio/static/assets/cynefinDiagram-5FMLGOSQ-BBrIG_mI.js +0 -62
- ksadk/studio/static/assets/dagre-GXQ25YYZ-DtF1nGdY.js +0 -4
- ksadk/studio/static/assets/diagram-UQ7AKVKN-6mLKEo6L.js +0 -41
- ksadk/studio/static/assets/diagram-VSXAHHWV-CJBIaiZ2.js +0 -3
- ksadk/studio/static/assets/diagram-VX7I27RA-BohLEE1C.js +0 -24
- ksadk/studio/static/assets/diagram-Z3DM3KII-D8KIGonG.js +0 -24
- ksadk/studio/static/assets/ebnfDiagram-PWID7BFC-C99HU61t.js +0 -1
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-B1_5Ac8j.js +0 -1
- ksadk/studio/static/assets/flowDiagram-HODETNUW-DD5hmicn.js +0 -1
- ksadk/studio/static/assets/ganttDiagram-EL5Y4UJY-BPJrVLSG.js +0 -292
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-Cy_ZQBGi.js +0 -1
- ksadk/studio/static/assets/gitGraphDiagram-WWUBYQGX-CZCUz4MT.js +0 -106
- ksadk/studio/static/assets/index-CeHL9ARV.css +0 -2
- ksadk/studio/static/assets/index-D9QEcVpL.js +0 -320
- ksadk/studio/static/assets/info-A6RAGUB7-DBzDQB_I.js +0 -1
- ksadk/studio/static/assets/infoDiagram-27XIBGKW-B-sq07Hi.js +0 -2
- ksadk/studio/static/assets/linear-BCxN9JLv.js +0 -1
- ksadk/studio/static/assets/mermaid-parser.core-BdCz8fkS.js +0 -7
- ksadk/studio/static/assets/packet-AYTQ26CC-gPln-_kG.js +0 -1
- ksadk/studio/static/assets/pegDiagram-XKGWAZYB-Dy3fB-gW.js +0 -1
- ksadk/studio/static/assets/pie-WAS4IAKB-qZdHMr7B.js +0 -1
- ksadk/studio/static/assets/radar-RG4KPBEZ-BZlnaea9.js +0 -1
- ksadk/studio/static/assets/railroad-74A4TZTK-Ce3__H9c.js +0 -1
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-DqQn7EzD.js +0 -1
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-B55kCA8F.js +0 -1
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-DfQnvkHd.js +0 -1
- ksadk/studio/static/assets/railroadDiagram-O6MQD6OU-DnhMjZCk.js +0 -1
- ksadk/studio/static/assets/sankeyDiagram-P5KCCOFB-Bo-JTwt0.js +0 -40
- ksadk/studio/static/assets/src-SFn9St9H.js +0 -1
- ksadk/studio/static/assets/stateDiagram-D77RDMKH-DH774G6d.js +0 -1
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-DZvVWPBo.js +0 -1
- ksadk/studio/static/assets/swimlanes-42K2YHIH-Bl13OvTX.js +0 -1
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-BnFOTALJ.js +0 -8
- ksadk/studio/static/assets/treeView-Q6P3EWNA-D5Nn9Swz.js +0 -1
- ksadk/studio/static/assets/treemap-WGGIJYW6-CgHgnQhE.js +0 -1
- ksadk/studio/static/assets/vennDiagram-4TSXK5OY-B9QEXcJq.js +0 -34
- ksadk/studio/static/assets/wardley-WFR3VGLG-DXrK2RRY.js +0 -1
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.5.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.5.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.5.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.5.dist-info}/top_level.txt +0 -0
- /ksadk/studio/static/assets/{MathMessageMarkdown-CBcDrAw--BEOyPC3w.css → MathMessageMarkdown-BesSeCYl-BEOyPC3w.css} +0 -0
|
@@ -0,0 +1,777 @@
|
|
|
1
|
+
"""Plugin lifecycle, transactional outbox dispatch and authoritative projection.
|
|
2
|
+
|
|
3
|
+
Owns no Agent Loop: every execution is submitted through the granted Host port.
|
|
4
|
+
The companion belongs to the Teams package and is started only by its enabled
|
|
5
|
+
profile. It does not initialize a database while disabled.
|
|
6
|
+
"""
|
|
7
|
+
|
|
8
|
+
from __future__ import annotations
|
|
9
|
+
|
|
10
|
+
import asyncio
|
|
11
|
+
import hashlib
|
|
12
|
+
import time
|
|
13
|
+
from pathlib import Path
|
|
14
|
+
from typing import Any
|
|
15
|
+
|
|
16
|
+
from ksadk.plugins.execution_host import ExecutionReceipt, PluginExecutionHost, PluginExecutionScope
|
|
17
|
+
|
|
18
|
+
from .contracts import API_VERSION, PLUGIN_VERSION, TERMINAL, Actor
|
|
19
|
+
from .domain import TeamsDomain
|
|
20
|
+
from .errors import TeamsError
|
|
21
|
+
from .store import TeamsStore, digest, now
|
|
22
|
+
|
|
23
|
+
TEAMS_PLUGIN_ID = "io.ksadk.teams"
|
|
24
|
+
TEAMS_PLUGIN_DIGEST = digest(
|
|
25
|
+
{"id": TEAMS_PLUGIN_ID, "version": PLUGIN_VERSION, "protocol": API_VERSION}
|
|
26
|
+
)
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
class TeamsRuntime:
|
|
30
|
+
def __init__(
|
|
31
|
+
self,
|
|
32
|
+
*,
|
|
33
|
+
path: Path,
|
|
34
|
+
authority_ref: str,
|
|
35
|
+
host: PluginExecutionHost,
|
|
36
|
+
poll_interval: float = 0.1,
|
|
37
|
+
plugin_digest: str = TEAMS_PLUGIN_DIGEST,
|
|
38
|
+
) -> None:
|
|
39
|
+
self.path = path
|
|
40
|
+
self.authority_ref = authority_ref
|
|
41
|
+
self.host = host
|
|
42
|
+
self.poll_interval = poll_interval
|
|
43
|
+
self.plugin_digest = plugin_digest
|
|
44
|
+
self.domain: TeamsDomain | None = None
|
|
45
|
+
self._task: asyncio.Task[None] | None = None
|
|
46
|
+
self._authority_file: Any = None
|
|
47
|
+
self._tick_lock = asyncio.Lock()
|
|
48
|
+
self.last_error: str | None = None
|
|
49
|
+
self._closing = False
|
|
50
|
+
self._shutdown_tasks: set[asyncio.Task] = set()
|
|
51
|
+
|
|
52
|
+
async def start(self, *, background: bool = True) -> None:
|
|
53
|
+
if self._closing and (self.domain is not None or self._shutdown_tasks):
|
|
54
|
+
raise TeamsError("shutdown_in_progress", "旧执行仍在关闭,请稍后重试", status=503)
|
|
55
|
+
self._closing = False
|
|
56
|
+
if self.domain is not None:
|
|
57
|
+
if background and self._task is None:
|
|
58
|
+
self._task = asyncio.create_task(self._run(), name="teams-plugin-outbox")
|
|
59
|
+
return
|
|
60
|
+
if self.path.exists():
|
|
61
|
+
import sqlite3
|
|
62
|
+
|
|
63
|
+
connection = sqlite3.connect(self.path.resolve().as_uri() + "?mode=ro", uri=True)
|
|
64
|
+
try:
|
|
65
|
+
exists = connection.execute(
|
|
66
|
+
"SELECT 1 FROM sqlite_master WHERE name='team_objects'"
|
|
67
|
+
).fetchone()
|
|
68
|
+
transferred = (
|
|
69
|
+
exists
|
|
70
|
+
and connection.execute(
|
|
71
|
+
"SELECT 1 FROM team_objects WHERE kind='installation' "
|
|
72
|
+
"AND object_id='teams:authority-transfer'"
|
|
73
|
+
).fetchone()
|
|
74
|
+
)
|
|
75
|
+
if transferred:
|
|
76
|
+
raise TeamsError(
|
|
77
|
+
"authority_transferred",
|
|
78
|
+
"本地团队历史已转为只读归档,请连接已迁移的团队服务端",
|
|
79
|
+
status=409,
|
|
80
|
+
)
|
|
81
|
+
finally:
|
|
82
|
+
connection.close()
|
|
83
|
+
self.path.parent.mkdir(parents=True, exist_ok=True)
|
|
84
|
+
self._authority_file = self.path.with_suffix(".authority.lock").open("a+b")
|
|
85
|
+
try:
|
|
86
|
+
self._lock_authority()
|
|
87
|
+
store = TeamsStore(self.path)
|
|
88
|
+
try:
|
|
89
|
+
with store.transaction() as tx:
|
|
90
|
+
installed = tx.get("installation", TEAMS_PLUGIN_ID, required=False)
|
|
91
|
+
has_groups = bool(tx.list("group"))
|
|
92
|
+
if installed and installed["pluginDigest"] != self.plugin_digest:
|
|
93
|
+
self._migrate_compatible_artifact(store, installed)
|
|
94
|
+
with store.transaction() as tx:
|
|
95
|
+
installed = tx.get("installation", TEAMS_PLUGIN_ID, required=False)
|
|
96
|
+
if installed is None and has_groups:
|
|
97
|
+
raise TeamsError(
|
|
98
|
+
"artifact_migration_required",
|
|
99
|
+
"团队数据绑定的插件制品已改变;请恢复原锁定版本或备份后执行版本迁移",
|
|
100
|
+
status=409,
|
|
101
|
+
)
|
|
102
|
+
if installed is None:
|
|
103
|
+
tx.put(
|
|
104
|
+
"installation",
|
|
105
|
+
TEAMS_PLUGIN_ID,
|
|
106
|
+
{
|
|
107
|
+
"pluginId": TEAMS_PLUGIN_ID,
|
|
108
|
+
"pluginDigest": self.plugin_digest,
|
|
109
|
+
"pluginVersion": PLUGIN_VERSION,
|
|
110
|
+
"apiVersion": API_VERSION,
|
|
111
|
+
},
|
|
112
|
+
)
|
|
113
|
+
self.domain = TeamsDomain(store, authority_ref=self.authority_ref)
|
|
114
|
+
except BaseException:
|
|
115
|
+
store.close()
|
|
116
|
+
raise
|
|
117
|
+
except BaseException:
|
|
118
|
+
self._authority_file.close()
|
|
119
|
+
self._authority_file = None
|
|
120
|
+
raise
|
|
121
|
+
if background:
|
|
122
|
+
self._task = asyncio.create_task(self._run(), name="teams-plugin-outbox")
|
|
123
|
+
|
|
124
|
+
def _migrate_compatible_artifact(
|
|
125
|
+
self, store: TeamsStore, installed: dict[str, Any]
|
|
126
|
+
) -> None:
|
|
127
|
+
if (
|
|
128
|
+
installed.get("pluginVersion") != PLUGIN_VERSION
|
|
129
|
+
or installed.get("apiVersion") != API_VERSION
|
|
130
|
+
):
|
|
131
|
+
raise TeamsError(
|
|
132
|
+
"artifact_migration_required",
|
|
133
|
+
"团队插件协议或数据版本不兼容;请使用专用迁移工具",
|
|
134
|
+
status=409,
|
|
135
|
+
)
|
|
136
|
+
transition = hashlib.sha256(
|
|
137
|
+
f"{installed['pluginDigest']}->{self.plugin_digest}".encode()
|
|
138
|
+
).hexdigest()[:16]
|
|
139
|
+
backup = self.path.with_name(f"{self.path.name}.pre-artifact-{transition}.bak")
|
|
140
|
+
store.backup(backup)
|
|
141
|
+
migrated = {
|
|
142
|
+
**installed,
|
|
143
|
+
"pluginDigest": self.plugin_digest,
|
|
144
|
+
"migratedAt": now(),
|
|
145
|
+
"previousPluginDigest": installed["pluginDigest"],
|
|
146
|
+
"migrationBackup": backup.name,
|
|
147
|
+
}
|
|
148
|
+
with store.transaction() as tx:
|
|
149
|
+
current = tx.get("installation", TEAMS_PLUGIN_ID)
|
|
150
|
+
if current["pluginDigest"] != installed["pluginDigest"]:
|
|
151
|
+
raise TeamsError(
|
|
152
|
+
"artifact_migration_conflict",
|
|
153
|
+
"团队插件制品迁移状态已改变,请重试",
|
|
154
|
+
status=409,
|
|
155
|
+
)
|
|
156
|
+
tx.put("installation", TEAMS_PLUGIN_ID, migrated)
|
|
157
|
+
|
|
158
|
+
def _lock_authority(self) -> None:
|
|
159
|
+
try:
|
|
160
|
+
import fcntl
|
|
161
|
+
except ImportError:
|
|
162
|
+
import msvcrt
|
|
163
|
+
|
|
164
|
+
self._authority_file.seek(0)
|
|
165
|
+
self._authority_file.write(b"0")
|
|
166
|
+
self._authority_file.flush()
|
|
167
|
+
self._authority_file.seek(0)
|
|
168
|
+
try:
|
|
169
|
+
msvcrt.locking(self._authority_file.fileno(), msvcrt.LK_NBLCK, 1)
|
|
170
|
+
except OSError as error:
|
|
171
|
+
raise TeamsError(
|
|
172
|
+
"authority_in_use", "该团队存储已有运行中的宿主", status=409
|
|
173
|
+
) from error
|
|
174
|
+
else:
|
|
175
|
+
try:
|
|
176
|
+
fcntl.flock(self._authority_file.fileno(), fcntl.LOCK_EX | fcntl.LOCK_NB)
|
|
177
|
+
except OSError as error:
|
|
178
|
+
raise TeamsError(
|
|
179
|
+
"authority_in_use", "该团队存储已有运行中的宿主", status=409
|
|
180
|
+
) from error
|
|
181
|
+
|
|
182
|
+
async def flush_controls(self, timeout: float = 2.0) -> None:
|
|
183
|
+
async def flush() -> None:
|
|
184
|
+
async with self._tick_lock:
|
|
185
|
+
if self.domain:
|
|
186
|
+
await self._controls(self.domain)
|
|
187
|
+
|
|
188
|
+
task = asyncio.create_task(flush(), name="teams-plugin-shutdown-controls")
|
|
189
|
+
self._shutdown_tasks.add(task)
|
|
190
|
+
|
|
191
|
+
def finished(completed: asyncio.Task) -> None:
|
|
192
|
+
self._shutdown_tasks.discard(completed)
|
|
193
|
+
if not completed.cancelled():
|
|
194
|
+
completed.exception() # Retrieve late host failures after the bounded wait.
|
|
195
|
+
|
|
196
|
+
task.add_done_callback(finished)
|
|
197
|
+
_, pending = await asyncio.wait({task}, timeout=timeout)
|
|
198
|
+
if pending:
|
|
199
|
+
task.cancel()
|
|
200
|
+
self.last_error = "teams_shutdown_timeout"
|
|
201
|
+
else:
|
|
202
|
+
await task
|
|
203
|
+
|
|
204
|
+
async def close(self, *, timeout: float = 2.0) -> None:
|
|
205
|
+
self._closing = True
|
|
206
|
+
pending = set(self._shutdown_tasks)
|
|
207
|
+
if self._task:
|
|
208
|
+
pending.add(self._task)
|
|
209
|
+
for task in pending:
|
|
210
|
+
task.cancel()
|
|
211
|
+
if pending:
|
|
212
|
+
_, pending = await asyncio.wait(pending, timeout=timeout)
|
|
213
|
+
if pending:
|
|
214
|
+
# Retain the store and authority lock while an uncooperative host
|
|
215
|
+
# call can still write. A replacement must never become authority.
|
|
216
|
+
self.last_error = "teams_shutdown_timeout"
|
|
217
|
+
return
|
|
218
|
+
self._task = None
|
|
219
|
+
try:
|
|
220
|
+
await asyncio.wait_for(self._tick_lock.acquire(), timeout=timeout)
|
|
221
|
+
except TimeoutError:
|
|
222
|
+
self.last_error = "teams_shutdown_timeout"
|
|
223
|
+
return
|
|
224
|
+
try:
|
|
225
|
+
if self.domain:
|
|
226
|
+
self.domain.store.close()
|
|
227
|
+
self.domain = None
|
|
228
|
+
if self._authority_file:
|
|
229
|
+
self._authority_file.close()
|
|
230
|
+
self._authority_file = None
|
|
231
|
+
finally:
|
|
232
|
+
self._tick_lock.release()
|
|
233
|
+
|
|
234
|
+
def require_domain(self) -> TeamsDomain:
|
|
235
|
+
if self.domain is None:
|
|
236
|
+
raise TeamsError("teams_disabled", "团队插件未启用", status=503)
|
|
237
|
+
return self.domain
|
|
238
|
+
|
|
239
|
+
async def _run(self) -> None:
|
|
240
|
+
while not self._closing:
|
|
241
|
+
try:
|
|
242
|
+
await self.tick()
|
|
243
|
+
self.last_error = None
|
|
244
|
+
except asyncio.CancelledError:
|
|
245
|
+
raise
|
|
246
|
+
except Exception:
|
|
247
|
+
# Never persist raw transport exceptions: URLs may contain host
|
|
248
|
+
# credentials. The health endpoint exposes a bounded error code.
|
|
249
|
+
self.last_error = "teams_reconciliation_failed"
|
|
250
|
+
await asyncio.sleep(self.poll_interval)
|
|
251
|
+
|
|
252
|
+
def _scope(self, group: dict[str, Any], member: dict[str, Any]) -> PluginExecutionScope:
|
|
253
|
+
return PluginExecutionScope(
|
|
254
|
+
plugin_id=TEAMS_PLUGIN_ID,
|
|
255
|
+
plugin_digest=self.plugin_digest,
|
|
256
|
+
authority_ref=self.authority_ref,
|
|
257
|
+
tenant_id=group["tenantId"],
|
|
258
|
+
owner_subject=group["ownerSubject"],
|
|
259
|
+
binding_ref=member["bindingRef"],
|
|
260
|
+
session_id=member["sessionId"],
|
|
261
|
+
)
|
|
262
|
+
|
|
263
|
+
@staticmethod
|
|
264
|
+
def grant_id(run_id: str, member_id: str) -> str:
|
|
265
|
+
return "grant_" + digest([run_id, member_id])[7:]
|
|
266
|
+
|
|
267
|
+
async def tick(self) -> None:
|
|
268
|
+
async with self._tick_lock:
|
|
269
|
+
if self._closing:
|
|
270
|
+
return
|
|
271
|
+
domain = self.require_domain()
|
|
272
|
+
# First close start eligibility, then reconcile accepted execution,
|
|
273
|
+
# then submit new work. No network operation holds a DB transaction.
|
|
274
|
+
self._watchdog(domain)
|
|
275
|
+
await self._controls(domain)
|
|
276
|
+
await self._member_controls(domain)
|
|
277
|
+
with domain.store.transaction() as tx:
|
|
278
|
+
deliveries = tx.list("delivery")
|
|
279
|
+
for delivery in deliveries:
|
|
280
|
+
if delivery["status"] in {"accepted", "uncertain"} and not delivery.get(
|
|
281
|
+
"_terminalState"
|
|
282
|
+
):
|
|
283
|
+
await self._reconcile(domain, delivery)
|
|
284
|
+
await self._settle_controls(domain)
|
|
285
|
+
await self._project_interactions(domain)
|
|
286
|
+
from .source_projection import project_sources
|
|
287
|
+
|
|
288
|
+
await project_sources(self, domain)
|
|
289
|
+
with domain.store.transaction() as tx:
|
|
290
|
+
candidates = tx.list("delivery")
|
|
291
|
+
for candidate in candidates:
|
|
292
|
+
if (
|
|
293
|
+
not self._closing
|
|
294
|
+
and candidate["status"] == "pending"
|
|
295
|
+
and candidate.get("_nextRetryAt", 0) <= time.time()
|
|
296
|
+
):
|
|
297
|
+
await self._submit(domain, candidate["deliveryId"])
|
|
298
|
+
|
|
299
|
+
async def _member_controls(self, domain):
|
|
300
|
+
with domain.store.transaction() as tx:
|
|
301
|
+
pending = [item for item in tx.list("member_control") if item["status"] == "pending"]
|
|
302
|
+
for control in pending:
|
|
303
|
+
with domain.store.transaction() as tx:
|
|
304
|
+
delivery = tx.get("delivery", control["deliveryId"])
|
|
305
|
+
group = tx.get("group", control["groupId"])
|
|
306
|
+
member = domain.delivery_member(tx, delivery)
|
|
307
|
+
if delivery.get("_terminalState"):
|
|
308
|
+
status = "settled"
|
|
309
|
+
else:
|
|
310
|
+
try:
|
|
311
|
+
receipt = await self.host.cancel(
|
|
312
|
+
self._scope(group, member),
|
|
313
|
+
run_id=control["runId"],
|
|
314
|
+
idempotency_key=control["controlId"],
|
|
315
|
+
)
|
|
316
|
+
except asyncio.CancelledError:
|
|
317
|
+
raise
|
|
318
|
+
except Exception:
|
|
319
|
+
continue
|
|
320
|
+
if receipt.status == "uncertain":
|
|
321
|
+
continue
|
|
322
|
+
status = "accepted" if receipt.status in {"accepted", "duplicate"} else "rejected"
|
|
323
|
+
with domain.store.transaction() as tx:
|
|
324
|
+
control["status"] = status
|
|
325
|
+
domain.publish(tx, "member_control", control["controlId"], control)
|
|
326
|
+
|
|
327
|
+
async def _project_interactions(self, domain: TeamsDomain) -> None:
|
|
328
|
+
if not callable(getattr(self.host, "interactions", None)):
|
|
329
|
+
return
|
|
330
|
+
with domain.store.transaction() as tx:
|
|
331
|
+
groups = tx.list("group")
|
|
332
|
+
for group in groups:
|
|
333
|
+
with domain.store.transaction() as tx:
|
|
334
|
+
deliveries = tx.list("delivery", group["groupId"])
|
|
335
|
+
members = list(
|
|
336
|
+
{d["_sessionId"]: domain.delivery_member(tx, d) for d in deliveries}.values()
|
|
337
|
+
)
|
|
338
|
+
known = tx.list("interaction", group["groupId"])
|
|
339
|
+
for member in members:
|
|
340
|
+
own = [
|
|
341
|
+
d
|
|
342
|
+
for d in deliveries
|
|
343
|
+
if d["memberId"] == member["memberId"]
|
|
344
|
+
and d["_sessionId"] == member["sessionId"]
|
|
345
|
+
and d.get("runId")
|
|
346
|
+
]
|
|
347
|
+
prior = [
|
|
348
|
+
i
|
|
349
|
+
for i in known
|
|
350
|
+
if i["ref"]["memberId"] == member["memberId"]
|
|
351
|
+
and i["ref"]["sessionId"] == member["sessionId"]
|
|
352
|
+
and i["status"] in {"pending", "resolving"}
|
|
353
|
+
]
|
|
354
|
+
if not prior and not any(not d.get("_terminalState") for d in own):
|
|
355
|
+
continue
|
|
356
|
+
scope = self._scope(group, member)
|
|
357
|
+
try:
|
|
358
|
+
records = await self.host.interactions(scope)
|
|
359
|
+
found = {i["interaction_id"] for i in records}
|
|
360
|
+
for item in prior:
|
|
361
|
+
if item["ref"]["interactionId"] not in found:
|
|
362
|
+
record = await self.host.get_interaction(
|
|
363
|
+
scope,
|
|
364
|
+
run_id=item["ref"]["runId"],
|
|
365
|
+
interaction_id=item["ref"]["interactionId"],
|
|
366
|
+
)
|
|
367
|
+
if record:
|
|
368
|
+
records.append(record)
|
|
369
|
+
except asyncio.CancelledError:
|
|
370
|
+
raise
|
|
371
|
+
except Exception:
|
|
372
|
+
continue
|
|
373
|
+
for record in records:
|
|
374
|
+
if not any(d["runId"] == record["run_id"] for d in own):
|
|
375
|
+
continue
|
|
376
|
+
ref = {
|
|
377
|
+
"authorityRef": self.authority_ref,
|
|
378
|
+
"groupId": group["groupId"],
|
|
379
|
+
"memberId": member["memberId"],
|
|
380
|
+
"bindingRef": member["bindingRef"],
|
|
381
|
+
"providerRef": member["binding"]["providerRef"],
|
|
382
|
+
"sessionId": member["sessionId"],
|
|
383
|
+
"runId": record["run_id"],
|
|
384
|
+
"interactionId": record["interaction_id"],
|
|
385
|
+
}
|
|
386
|
+
presentation = record.get("presentation") or {}
|
|
387
|
+
projected = {
|
|
388
|
+
"groupId": group["groupId"],
|
|
389
|
+
"teamRunId": member["teamRunId"],
|
|
390
|
+
"ref": ref,
|
|
391
|
+
"revision": record["revision"],
|
|
392
|
+
"title": presentation.get("title") or "等待你的确认",
|
|
393
|
+
"message": presentation.get("description")
|
|
394
|
+
or "请查看此成员的请求并作出决定。",
|
|
395
|
+
"kind": "approval" if record["kind"] == "approval" else "input",
|
|
396
|
+
"status": record["status"],
|
|
397
|
+
"requestSchema": record.get("request_schema"),
|
|
398
|
+
"createdAt": record["created_at"],
|
|
399
|
+
}
|
|
400
|
+
key = "interaction_" + digest(ref)[7:]
|
|
401
|
+
with domain.store.transaction() as tx:
|
|
402
|
+
previous = tx.get("interaction", key, required=False)
|
|
403
|
+
if previous != projected:
|
|
404
|
+
domain.publish(tx, "interaction", key, projected)
|
|
405
|
+
|
|
406
|
+
async def _submit(self, domain: TeamsDomain, delivery_id: str) -> None:
|
|
407
|
+
with domain.store.transaction() as tx:
|
|
408
|
+
delivery = tx.get("delivery", delivery_id)
|
|
409
|
+
run = tx.get("team_run", delivery["teamRunId"])
|
|
410
|
+
group = tx.get("group", delivery["groupId"])
|
|
411
|
+
member = domain.run_member(tx, run["teamRunId"], delivery["memberId"])
|
|
412
|
+
if (
|
|
413
|
+
delivery["status"] != "pending"
|
|
414
|
+
or delivery.get("_fenced")
|
|
415
|
+
or run["dispatchSuspended"]
|
|
416
|
+
or run["status"] in TERMINAL | {"cancel_requested"}
|
|
417
|
+
):
|
|
418
|
+
return
|
|
419
|
+
if delivery["_dispatchEpoch"] != run["dispatchEpoch"] or member["status"] != "active":
|
|
420
|
+
delivery.update(
|
|
421
|
+
status="cancelled",
|
|
422
|
+
reason="authorization_changed",
|
|
423
|
+
revision=delivery["revision"] + 1,
|
|
424
|
+
)
|
|
425
|
+
domain.publish(tx, "delivery", delivery_id, delivery)
|
|
426
|
+
return
|
|
427
|
+
# One outstanding dispatch per member preserves order and leaves
|
|
428
|
+
# concurrent slots available to other members.
|
|
429
|
+
outstanding = [
|
|
430
|
+
item
|
|
431
|
+
for item in tx.list("delivery", group["groupId"], team_run_id=run["teamRunId"])
|
|
432
|
+
if item["status"] in {"accepted", "uncertain"} and not item.get("_terminalState")
|
|
433
|
+
]
|
|
434
|
+
admitted = [item for item in outstanding if not item.get("_fenced")]
|
|
435
|
+
if len(admitted) >= run["budget"]["maxConcurrent"] or any(
|
|
436
|
+
item["memberId"] == member["memberId"] for item in admitted
|
|
437
|
+
):
|
|
438
|
+
return
|
|
439
|
+
available_tokens = (
|
|
440
|
+
run["budget"]["maxTokens"]
|
|
441
|
+
- run["budget"]["tokensUsed"]
|
|
442
|
+
- sum(item.get("_tokenLimit", 0) for item in outstanding)
|
|
443
|
+
)
|
|
444
|
+
if available_tokens <= 0:
|
|
445
|
+
return
|
|
446
|
+
token_limit = min(
|
|
447
|
+
available_tokens,
|
|
448
|
+
max(
|
|
449
|
+
1,
|
|
450
|
+
run["budget"]["maxTokens"]
|
|
451
|
+
// min(run["budget"]["maxConcurrent"], len(run["_roster"])),
|
|
452
|
+
),
|
|
453
|
+
)
|
|
454
|
+
scope = self._scope(group, member)
|
|
455
|
+
policy_context = {
|
|
456
|
+
"groupId": group["groupId"],
|
|
457
|
+
"teamRunId": run["teamRunId"],
|
|
458
|
+
"memberId": member["memberId"],
|
|
459
|
+
"taskId": delivery.get("_taskId"),
|
|
460
|
+
"attemptId": delivery.get("_attemptId"),
|
|
461
|
+
"deliveryId": delivery_id,
|
|
462
|
+
"groupRevision": run["groupRevision"],
|
|
463
|
+
"dispatchEpoch": run["dispatchEpoch"],
|
|
464
|
+
"tokenLimit": token_limit,
|
|
465
|
+
"workspace": run.get("workspace"),
|
|
466
|
+
}
|
|
467
|
+
try:
|
|
468
|
+
await self.host.ensure_session(scope)
|
|
469
|
+
except asyncio.CancelledError:
|
|
470
|
+
raise
|
|
471
|
+
except Exception as error:
|
|
472
|
+
code = str(getattr(error, "code", "execution_preflight_failed"))
|
|
473
|
+
if code in {"execution_node_offline", "node_offline", "node_unavailable"}:
|
|
474
|
+
with domain.store.transaction() as tx:
|
|
475
|
+
current = tx.get("delivery", delivery_id)
|
|
476
|
+
if current["status"] == "pending":
|
|
477
|
+
current.update(
|
|
478
|
+
reason="waiting_for_node",
|
|
479
|
+
_nextRetryAt=time.time() + 5,
|
|
480
|
+
revision=current["revision"] + 1,
|
|
481
|
+
)
|
|
482
|
+
domain.publish(tx, "delivery", delivery_id, current)
|
|
483
|
+
else:
|
|
484
|
+
safe_code = (
|
|
485
|
+
code
|
|
486
|
+
if code
|
|
487
|
+
in {
|
|
488
|
+
"BUILD_UNAVAILABLE",
|
|
489
|
+
"PROVIDER_UNAVAILABLE",
|
|
490
|
+
"binding_unavailable",
|
|
491
|
+
"binding_unsupported",
|
|
492
|
+
"member_revoked",
|
|
493
|
+
}
|
|
494
|
+
else "execution_preflight_failed"
|
|
495
|
+
)
|
|
496
|
+
self._receipt(domain, delivery_id, ExecutionReceipt("rejected", reason=safe_code))
|
|
497
|
+
return
|
|
498
|
+
# Preparation cannot execute. Only the submit boundary creates uncertain
|
|
499
|
+
# admission, after rechecking a stop that may have arrived during preflight.
|
|
500
|
+
with domain.store.transaction() as tx:
|
|
501
|
+
current = tx.get("delivery", delivery_id)
|
|
502
|
+
latest = tx.get("team_run", delivery["teamRunId"])
|
|
503
|
+
if (
|
|
504
|
+
self._closing
|
|
505
|
+
or current["status"] != "pending"
|
|
506
|
+
or latest["dispatchSuspended"]
|
|
507
|
+
or latest["status"] in TERMINAL | {"cancel_requested"}
|
|
508
|
+
or current["_dispatchEpoch"] != latest["dispatchEpoch"]
|
|
509
|
+
):
|
|
510
|
+
return
|
|
511
|
+
current.update(
|
|
512
|
+
status="uncertain",
|
|
513
|
+
_tokenLimit=token_limit,
|
|
514
|
+
reason=None,
|
|
515
|
+
revision=current["revision"] + 1,
|
|
516
|
+
)
|
|
517
|
+
domain.publish(tx, "delivery", delivery_id, current)
|
|
518
|
+
try:
|
|
519
|
+
receipt = await self.host.submit(
|
|
520
|
+
scope,
|
|
521
|
+
content=delivery["_payload"],
|
|
522
|
+
idempotency_key=delivery_id,
|
|
523
|
+
grant_id=self.grant_id(run["teamRunId"], member["memberId"]),
|
|
524
|
+
causation=delivery["_decisionId"],
|
|
525
|
+
policy_context=policy_context,
|
|
526
|
+
)
|
|
527
|
+
except asyncio.CancelledError:
|
|
528
|
+
raise
|
|
529
|
+
except Exception:
|
|
530
|
+
# Persisted uncertain state is intentional; the next tick looks up
|
|
531
|
+
# the original command before deciding whether a retry is needed.
|
|
532
|
+
return
|
|
533
|
+
self._receipt(domain, delivery_id, receipt)
|
|
534
|
+
|
|
535
|
+
def _watchdog(self, domain: TeamsDomain) -> None:
|
|
536
|
+
with domain.store.transaction() as tx:
|
|
537
|
+
runs = tx.list("team_run")
|
|
538
|
+
for run in runs:
|
|
539
|
+
if run["status"] in TERMINAL | {"cancel_requested", "awaiting_acceptance"}:
|
|
540
|
+
continue
|
|
541
|
+
with domain.store.transaction() as tx:
|
|
542
|
+
run = tx.get("team_run", run["teamRunId"])
|
|
543
|
+
domain.update_active_clock(tx, run)
|
|
544
|
+
tx.put("team_run", run["teamRunId"], run)
|
|
545
|
+
elapsed = run.get("activeDurationSeconds", 0)
|
|
546
|
+
reason = (
|
|
547
|
+
"duration_budget_exhausted"
|
|
548
|
+
if elapsed >= run["budget"]["maxDurationSeconds"]
|
|
549
|
+
else "token_budget_exhausted"
|
|
550
|
+
if run["budget"]["tokensUsed"] >= run["budget"]["maxTokens"]
|
|
551
|
+
else None
|
|
552
|
+
)
|
|
553
|
+
if reason:
|
|
554
|
+
with domain.store.transaction() as tx:
|
|
555
|
+
group = tx.get("group", run["groupId"])
|
|
556
|
+
domain.control(
|
|
557
|
+
Actor(group["tenantId"], group["ownerSubject"], kind="host"),
|
|
558
|
+
run["groupId"],
|
|
559
|
+
run["teamRunId"],
|
|
560
|
+
"stop",
|
|
561
|
+
run["revision"],
|
|
562
|
+
f"budget:{run['teamRunId']}:{reason}",
|
|
563
|
+
)
|
|
564
|
+
with domain.store.transaction() as tx:
|
|
565
|
+
latest = tx.get("team_run", run["teamRunId"])
|
|
566
|
+
latest.update(reason=reason, revision=latest["revision"] + 1)
|
|
567
|
+
domain.publish(tx, "team_run", latest["teamRunId"], latest)
|
|
568
|
+
|
|
569
|
+
async def _reconcile(self, domain: TeamsDomain, delivery: dict[str, Any]) -> None:
|
|
570
|
+
with domain.store.transaction() as tx:
|
|
571
|
+
group = tx.get("group", delivery["groupId"])
|
|
572
|
+
member = domain.delivery_member(tx, delivery)
|
|
573
|
+
try:
|
|
574
|
+
receipt = await self.host.lookup(self._scope(group, member), delivery["deliveryId"])
|
|
575
|
+
except asyncio.CancelledError:
|
|
576
|
+
raise
|
|
577
|
+
except Exception:
|
|
578
|
+
return
|
|
579
|
+
if receipt.status == "missing":
|
|
580
|
+
if delivery["status"] == "uncertain" and not delivery.get("_fenced"):
|
|
581
|
+
with domain.store.transaction() as tx:
|
|
582
|
+
current = tx.get("delivery", delivery["deliveryId"])
|
|
583
|
+
run = tx.get("team_run", current["teamRunId"])
|
|
584
|
+
current.update(
|
|
585
|
+
status="cancelled"
|
|
586
|
+
if run["status"] in TERMINAL | {"cancel_requested"}
|
|
587
|
+
else "pending",
|
|
588
|
+
revision=current["revision"] + 1,
|
|
589
|
+
_nextRetryAt=time.time() + 0.25,
|
|
590
|
+
)
|
|
591
|
+
domain.publish(tx, "delivery", current["deliveryId"], current)
|
|
592
|
+
return
|
|
593
|
+
self._receipt(domain, delivery["deliveryId"], receipt)
|
|
594
|
+
if receipt.run_id and receipt.run_status:
|
|
595
|
+
with domain.store.transaction() as tx:
|
|
596
|
+
current = tx.get("delivery", delivery["deliveryId"])
|
|
597
|
+
if current.get("_runStatus") == receipt.run_status:
|
|
598
|
+
return
|
|
599
|
+
# A run may return to running after offline/approval waits. The
|
|
600
|
+
# same native running event must not suppress this new transition.
|
|
601
|
+
event_id = digest([receipt.run_id, receipt.run_status, current["revision"]])
|
|
602
|
+
domain.project_run(
|
|
603
|
+
delivery_id=delivery["deliveryId"],
|
|
604
|
+
event_id=event_id,
|
|
605
|
+
run_id=receipt.run_id,
|
|
606
|
+
status=receipt.run_status,
|
|
607
|
+
output=receipt.output,
|
|
608
|
+
tokens=receipt.tokens,
|
|
609
|
+
)
|
|
610
|
+
|
|
611
|
+
@staticmethod
|
|
612
|
+
def _receipt(domain: TeamsDomain, delivery_id: str, receipt: ExecutionReceipt) -> None:
|
|
613
|
+
with domain.store.transaction() as tx:
|
|
614
|
+
delivery = tx.get("delivery", delivery_id)
|
|
615
|
+
if delivery.get("_terminalState"):
|
|
616
|
+
return
|
|
617
|
+
status = "accepted" if receipt.status in {"accepted", "duplicate"} else receipt.status
|
|
618
|
+
if status not in {"accepted", "rejected", "uncertain"}:
|
|
619
|
+
return
|
|
620
|
+
update = {
|
|
621
|
+
"status": status,
|
|
622
|
+
"commandId": receipt.command_id,
|
|
623
|
+
"runId": receipt.run_id,
|
|
624
|
+
"_kernelMessageId": receipt.message_id,
|
|
625
|
+
"reason": receipt.reason,
|
|
626
|
+
}
|
|
627
|
+
if all(delivery.get(key) == value for key, value in update.items()):
|
|
628
|
+
return
|
|
629
|
+
delivery.update(**update, revision=delivery["revision"] + 1)
|
|
630
|
+
domain.publish(tx, "delivery", delivery_id, delivery)
|
|
631
|
+
if status == "rejected":
|
|
632
|
+
run = tx.get("team_run", delivery["teamRunId"])
|
|
633
|
+
if run["status"] not in TERMINAL | {"cancel_requested"}:
|
|
634
|
+
run.update(
|
|
635
|
+
status="needs_attention",
|
|
636
|
+
reason=receipt.reason or "delivery_rejected",
|
|
637
|
+
revision=run["revision"] + 1,
|
|
638
|
+
)
|
|
639
|
+
domain.publish(tx, "team_run", run["teamRunId"], run)
|
|
640
|
+
if delivery.get("_taskId"):
|
|
641
|
+
task = tx.get("task", delivery["_taskId"])
|
|
642
|
+
if task["attempts"] and task["attempts"][-1]["attemptId"] == delivery.get(
|
|
643
|
+
"_attemptId"
|
|
644
|
+
):
|
|
645
|
+
task.update(
|
|
646
|
+
status="failed",
|
|
647
|
+
reason=receipt.reason or "delivery_rejected",
|
|
648
|
+
revision=task["revision"] + 1,
|
|
649
|
+
)
|
|
650
|
+
task["attempts"][-1]["status"] = "failed"
|
|
651
|
+
domain.publish(tx, "task", task["taskId"], task)
|
|
652
|
+
member = domain.delivery_member(tx, delivery)
|
|
653
|
+
member.update(
|
|
654
|
+
executionStatus="idle", activeRunId=None, revision=member["revision"] + 1
|
|
655
|
+
)
|
|
656
|
+
current = domain.run_member(tx, delivery["teamRunId"], delivery["memberId"])
|
|
657
|
+
if current["sessionId"] == member["sessionId"]:
|
|
658
|
+
member["revision"] = current["revision"] + 1
|
|
659
|
+
domain.publish_run_member(tx, member)
|
|
660
|
+
domain._advance(tx, run)
|
|
661
|
+
|
|
662
|
+
async def _controls(self, domain: TeamsDomain) -> None:
|
|
663
|
+
with domain.store.transaction() as tx:
|
|
664
|
+
controls = [control for control in tx.list("control") if control["status"] == "pending"]
|
|
665
|
+
for control in controls:
|
|
666
|
+
with domain.store.transaction() as tx:
|
|
667
|
+
group = tx.get("group", control["groupId"])
|
|
668
|
+
run = tx.get("team_run", control["teamRunId"])
|
|
669
|
+
if control["epoch"] != run["dispatchEpoch"]:
|
|
670
|
+
control["status"] = "superseded"
|
|
671
|
+
tx.put("control", control["controlId"], control)
|
|
672
|
+
continue
|
|
673
|
+
members = run["_roster"]
|
|
674
|
+
state = {
|
|
675
|
+
"stop": "revoked",
|
|
676
|
+
"suspend_dispatch": "suspended",
|
|
677
|
+
"resume_dispatch": "active",
|
|
678
|
+
}[control["action"]]
|
|
679
|
+
for member in members:
|
|
680
|
+
if member["memberId"] in control["barriers"]:
|
|
681
|
+
continue
|
|
682
|
+
with domain.store.transaction() as tx:
|
|
683
|
+
latest = tx.get("team_run", control["teamRunId"])
|
|
684
|
+
if latest["dispatchEpoch"] != control["epoch"]:
|
|
685
|
+
break
|
|
686
|
+
scope = self._scope(group, member)
|
|
687
|
+
try:
|
|
688
|
+
barrier = await self.host.set_grant(
|
|
689
|
+
scope,
|
|
690
|
+
self.grant_id(run["teamRunId"], member["memberId"]),
|
|
691
|
+
state,
|
|
692
|
+
f"{control['controlId']}:{member['memberId']}",
|
|
693
|
+
)
|
|
694
|
+
except asyncio.CancelledError:
|
|
695
|
+
raise
|
|
696
|
+
except Exception:
|
|
697
|
+
continue
|
|
698
|
+
with domain.store.transaction() as tx:
|
|
699
|
+
current = tx.get("control", control["controlId"])
|
|
700
|
+
current["barriers"][member["memberId"]] = {
|
|
701
|
+
"state": barrier.state,
|
|
702
|
+
"revision": barrier.revision,
|
|
703
|
+
"inFlight": list(barrier.in_flight),
|
|
704
|
+
}
|
|
705
|
+
tx.put("control", current["controlId"], current)
|
|
706
|
+
control = current
|
|
707
|
+
if len(control["barriers"]) == len(members):
|
|
708
|
+
with domain.store.transaction() as tx:
|
|
709
|
+
latest = tx.get("team_run", control["teamRunId"])
|
|
710
|
+
control["status"] = (
|
|
711
|
+
"barriers_confirmed"
|
|
712
|
+
if latest["dispatchEpoch"] == control["epoch"]
|
|
713
|
+
else "superseded"
|
|
714
|
+
)
|
|
715
|
+
tx.put("control", control["controlId"], control)
|
|
716
|
+
|
|
717
|
+
async def _settle_controls(self, domain: TeamsDomain) -> None:
|
|
718
|
+
with domain.store.transaction() as tx:
|
|
719
|
+
controls = [
|
|
720
|
+
control
|
|
721
|
+
for control in tx.list("control")
|
|
722
|
+
if control["status"] == "barriers_confirmed"
|
|
723
|
+
]
|
|
724
|
+
for control in controls:
|
|
725
|
+
if control["action"] != "stop":
|
|
726
|
+
with domain.store.transaction() as tx:
|
|
727
|
+
run = tx.get("team_run", control["teamRunId"])
|
|
728
|
+
if run["dispatchEpoch"] != control["epoch"]:
|
|
729
|
+
control["status"] = "superseded"
|
|
730
|
+
else:
|
|
731
|
+
control["status"] = "completed"
|
|
732
|
+
if control["action"] == "resume_dispatch":
|
|
733
|
+
run.update(
|
|
734
|
+
dispatchSuspended=False,
|
|
735
|
+
revision=run["revision"] + 1,
|
|
736
|
+
updatedAt=now(),
|
|
737
|
+
)
|
|
738
|
+
domain.publish(tx, "team_run", run["teamRunId"], run)
|
|
739
|
+
tx.put("control", control["controlId"], control)
|
|
740
|
+
continue
|
|
741
|
+
with domain.store.transaction() as tx:
|
|
742
|
+
group = tx.get("group", control["groupId"])
|
|
743
|
+
deliveries = tx.list(
|
|
744
|
+
"delivery", control["groupId"], team_run_id=control["teamRunId"]
|
|
745
|
+
)
|
|
746
|
+
members = {d["deliveryId"]: domain.delivery_member(tx, d) for d in deliveries}
|
|
747
|
+
pending = False
|
|
748
|
+
for delivery in deliveries:
|
|
749
|
+
if delivery["status"] == "uncertain" or (
|
|
750
|
+
delivery["status"] == "accepted" and not delivery.get("_terminalState")
|
|
751
|
+
):
|
|
752
|
+
pending = True
|
|
753
|
+
if delivery.get("runId"):
|
|
754
|
+
try:
|
|
755
|
+
await self.host.cancel(
|
|
756
|
+
self._scope(group, members[delivery["deliveryId"]]),
|
|
757
|
+
delivery["runId"],
|
|
758
|
+
f"{control['controlId']}:{delivery['runId']}",
|
|
759
|
+
)
|
|
760
|
+
except asyncio.CancelledError:
|
|
761
|
+
raise
|
|
762
|
+
except Exception:
|
|
763
|
+
continue
|
|
764
|
+
if pending:
|
|
765
|
+
continue
|
|
766
|
+
with domain.store.transaction() as tx:
|
|
767
|
+
run = tx.get("team_run", control["teamRunId"])
|
|
768
|
+
run.update(status="cancelled", revision=run["revision"] + 1, updatedAt=now())
|
|
769
|
+
domain.publish(tx, "team_run", run["teamRunId"], run)
|
|
770
|
+
for task in tx.list("task", group["groupId"], team_run_id=run["teamRunId"]):
|
|
771
|
+
if task["status"] not in TERMINAL:
|
|
772
|
+
task.update(status="cancelled", revision=task["revision"] + 1)
|
|
773
|
+
if task["attempts"]:
|
|
774
|
+
task["attempts"][-1]["status"] = "cancelled"
|
|
775
|
+
domain.publish(tx, "task", task["taskId"], task)
|
|
776
|
+
control["status"] = "completed"
|
|
777
|
+
tx.put("control", control["controlId"], control)
|