agentengine-sdk-python 0.8.4__py3-none-any.whl → 0.8.6__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.6.dist-info}/METADATA +17 -10
- agentengine_sdk_python-0.8.6.dist-info/RECORD +1731 -0
- ksadk/_async_iterators.py +79 -0
- ksadk/_build_provenance.json +1 -1
- ksadk/_model_anthropic.py +49 -0
- ksadk/_model_input.py +86 -0
- ksadk/_model_json.py +40 -0
- ksadk/_model_reasoning.py +17 -0
- ksadk/_model_refusal.py +20 -0
- ksadk/_model_sse.py +163 -0
- ksadk/_process.py +83 -0
- ksadk/_str_enum.py +17 -0
- ksadk/a2a/__init__.py +157 -167
- ksadk/a2a/_invocation_state.py +86 -0
- ksadk/a2a/_space_client_events.py +33 -22
- ksadk/a2a/adk.py +194 -0
- ksadk/a2a/adk_invocation_context.py +242 -0
- ksadk/a2a/adk_runtime.py +126 -0
- ksadk/a2a/adk_tools.py +319 -0
- ksadk/a2a/bootstrap.py +149 -23
- ksadk/a2a/build_validation.py +147 -0
- ksadk/a2a/card.py +23 -15
- ksadk/a2a/codex.py +160 -0
- ksadk/a2a/codex_checkpoint.py +111 -0
- ksadk/a2a/codex_recovery.py +96 -0
- ksadk/a2a/codex_recovery_events.py +123 -0
- ksadk/a2a/codex_runtime.py +198 -0
- ksadk/a2a/codex_session_checkpoint.py +162 -0
- ksadk/a2a/composition.py +88 -0
- ksadk/a2a/context_store.py +118 -19
- ksadk/a2a/control_plane.py +108 -106
- ksadk/a2a/event_adapter.py +92 -193
- ksadk/a2a/executor.py +257 -85
- ksadk/a2a/exposure.py +106 -0
- ksadk/a2a/external_transport.py +3 -4
- ksadk/a2a/identity.py +106 -12
- ksadk/a2a/ids.py +14 -3
- ksadk/a2a/inbound_kernel.py +133 -0
- ksadk/a2a/interaction_wire.py +76 -0
- ksadk/a2a/invocation_checkpoint.py +274 -0
- ksadk/a2a/invocation_policy.py +87 -0
- ksadk/a2a/invocation_publication.py +210 -0
- ksadk/a2a/invocation_service.py +972 -0
- ksadk/a2a/invocation_types.py +459 -0
- ksadk/a2a/kernel_task_adapter.py +259 -0
- ksadk/a2a/langgraph.py +20 -7
- ksadk/a2a/langgraph_invocation_context.py +136 -0
- ksadk/a2a/langgraph_managed.py +150 -0
- ksadk/a2a/langgraph_recovery.py +32 -0
- ksadk/a2a/langgraph_runtime.py +89 -0
- ksadk/a2a/langgraph_tool_runtime.py +132 -0
- ksadk/a2a/langgraph_tools.py +63 -0
- ksadk/a2a/message_digest.py +40 -0
- ksadk/a2a/platform.py +389 -0
- ksadk/a2a/policy_refs.py +13 -0
- ksadk/a2a/presentation.py +402 -0
- ksadk/a2a/product_kernel_facts.py +177 -0
- ksadk/a2a/product_key.py +99 -0
- ksadk/a2a/protocol_errors.py +116 -0
- ksadk/a2a/result_text.py +49 -0
- ksadk/a2a/resume_store.py +93 -3
- ksadk/a2a/routes.py +6 -1
- ksadk/a2a/runtime_approval.py +198 -0
- ksadk/a2a/runtime_input.py +151 -0
- ksadk/a2a/server.py +16 -7
- ksadk/a2a/space_client.py +101 -16
- ksadk/a2a/task_adapter.py +19 -5
- ksadk/a2a/task_event_dispatcher.py +39 -2
- ksadk/a2a/task_event_outbox.py +215 -0
- ksadk/a2a/task_event_outbox_owned.py +130 -0
- ksadk/a2a/task_store.py +37 -0
- ksadk/a2a/tool_activity.py +176 -0
- ksadk/a2a/workload_tokens.py +134 -0
- ksadk/a2ui/core.py +3 -3
- ksadk/api/client.py +38 -79
- ksadk/api/sse_stream.py +96 -0
- ksadk/builders/code_builder.py +121 -118
- ksadk/builders/container_builder.py +11 -29
- ksadk/builders/framework_requirements.py +22 -2
- ksadk/builders/managed_runtime_builder.py +12 -0
- ksadk/builders/source_provenance.py +87 -0
- ksadk/cli/__init__.py +36 -0
- ksadk/cli/cmd_a2a.py +43 -0
- ksadk/cli/cmd_build.py +9 -0
- ksadk/cli/cmd_config.py +4 -4
- ksadk/cli/cmd_create.py +12 -12
- ksadk/cli/cmd_deploy.py +27 -2
- ksadk/cli/cmd_hermes.py +24 -2
- ksadk/cli/cmd_invoke.py +64 -88
- ksadk/cli/cmd_openclaw.py +26 -1
- ksadk/cli/cmd_plugin.py +70 -12
- ksadk/cli/cmd_studio.py +69 -17
- ksadk/cli/cmd_web.py +2 -0
- ksadk/cli/hosted_invoke.py +206 -0
- ksadk/cli/invoke_content.py +60 -0
- ksadk/cli/openclaw_env.py +1 -1
- ksadk/cli/resource_common.py +26 -0
- ksadk/cli/runtime_bootstrap.py +27 -5
- ksadk/codex/_expert_request_reader.py +48 -0
- ksadk/codex/a2a_tools.py +140 -0
- ksadk/codex/async_approval.py +169 -0
- ksadk/codex/async_client.py +938 -0
- ksadk/codex/async_proxy.py +216 -0
- ksadk/codex/base_runtime.py +25 -0
- ksadk/codex/client.py +3 -1047
- ksadk/codex/client_payloads.py +85 -0
- ksadk/codex/rollout_checkpoint.py +264 -0
- ksadk/codex/runtime.py +290 -54
- ksadk/common/auth.py +2 -2
- ksadk/common/cloud_headers.py +36 -0
- ksadk/common/diagnostics.py +34 -0
- ksadk/common/kop_client.py +2 -1
- ksadk/configs/__init__.py +1 -1
- ksadk/configs/env_registry.py +216 -143
- ksadk/configs/env_registry_a2a.py +173 -0
- ksadk/configs/env_registry_studio.py +134 -0
- ksadk/configs/global_config.py +2 -1
- ksadk/configs/settings.py +9 -3
- ksadk/connector/__init__.py +17 -0
- ksadk/connector/channel.py +477 -0
- ksadk/context_engine/assembler.py +9 -0
- ksadk/context_engine/capabilities.py +52 -4
- ksadk/context_engine/contributors.py +80 -17
- ksadk/context_engine/instruction_authority.py +18 -0
- ksadk/conversations/attachment_storage.py +10 -3
- ksadk/conversations/attachments.py +69 -20
- ksadk/conversations/contracts.py +28 -9
- ksadk/conversations/message_projection.py +51 -155
- ksadk/conversations/message_projection_blocks.py +137 -0
- ksadk/conversations/model_context.py +11 -3
- ksadk/conversations/normalize.py +28 -10
- ksadk/conversations/projector.py +63 -0
- ksadk/conversations/runtime_baseline.py +37 -0
- ksadk/conversations/runtime_compaction.py +7 -2
- ksadk/conversations/runtime_input.py +16 -4
- ksadk/conversations/runtime_invocation.py +17 -4
- ksadk/conversations/runtime_observability.py +39 -10
- ksadk/conversations/runtime_payloads.py +12 -0
- ksadk/conversations/runtime_persistence.py +296 -32
- ksadk/conversations/runtime_preparation.py +98 -13
- ksadk/conversations/runtime_projection.py +217 -0
- ksadk/conversations/runtime_resume.py +141 -70
- ksadk/conversations/runtime_stream_events.py +29 -35
- ksadk/conversations/runtime_streaming.py +8 -0
- ksadk/conversations/tool_receipt_resume.py +387 -0
- ksadk/conversations/tool_receipts.py +32 -0
- ksadk/deployment/env_forward.py +5 -0
- ksadk/deployment/manager.py +15 -6
- ksadk/deployment/providers/serverless.py +76 -136
- ksadk/deployment/providers/serverless_payloads.py +122 -0
- ksadk/evaluation/agent_eval_client.py +2 -1
- ksadk/evaluation/contracts.py +78 -3
- ksadk/evaluation/evaluators.py +166 -1
- ksadk/evaluation/evidence.py +271 -4
- ksadk/evaluation/local_adapter.py +76 -12
- ksadk/evaluation/studio_build_adapter.py +73 -9
- ksadk/events/adapters/_a2a_checkpoint.py +151 -0
- ksadk/events/adapters/_a2a_snapshot.py +18 -14
- ksadk/events/adapters/_a2a_support.py +15 -3
- ksadk/events/adapters/_a2a_tool_activity.py +123 -0
- ksadk/events/adapters/_codex_errors.py +49 -0
- ksadk/events/adapters/_codex_items.py +16 -8
- ksadk/events/adapters/_langgraph_support.py +46 -1
- ksadk/events/adapters/a2a.py +54 -26
- ksadk/events/adapters/adk.py +188 -30
- ksadk/events/adapters/codex.py +33 -7
- ksadk/events/adapters/langgraph.py +16 -6
- ksadk/events/canonical.py +5 -0
- ksadk/events/canonical_store.py +200 -4
- ksadk/events/reducer.py +82 -0
- ksadk/events/run_authority.py +176 -0
- ksadk/events/session_event.py +2 -2
- ksadk/harness/__init__.py +18 -0
- ksadk/harness/app.py +11 -0
- ksadk/harness/artifact_adapters/__init__.py +1 -0
- ksadk/harness/artifact_adapters/native_page_budget.py +172 -0
- ksadk/harness/artifact_adapters/native_search.py +249 -0
- ksadk/harness/artifact_adapters/native_search_budget.py +134 -0
- ksadk/harness/artifact_adapters/native_store.py +115 -0
- ksadk/harness/artifact_adapters/native_tool.py +222 -0
- ksadk/harness/artifact_store.py +230 -0
- ksadk/harness/browser_adapters/__init__.py +6 -0
- ksadk/harness/browser_adapters/native_browser_tool.py +92 -0
- ksadk/harness/browser_adapters/native_dom_snapshot.py +187 -0
- ksadk/harness/browser_adapters/native_playwright.py +953 -0
- ksadk/harness/browser_adapters/native_vision.py +295 -0
- ksadk/harness/capabilities.py +115 -0
- ksadk/harness/capability_adapters/__init__.py +1 -0
- ksadk/harness/capability_adapters/native_dsh.py +289 -0
- ksadk/harness/capability_runtime.py +332 -0
- ksadk/harness/closure_contract.py +92 -0
- ksadk/harness/compaction_record.py +153 -0
- ksadk/harness/compiler.py +284 -0
- ksadk/harness/config.py +28 -5
- ksadk/harness/conformance/__init__.py +33 -0
- ksadk/harness/conformance/contract.py +504 -0
- ksadk/harness/conformance/fixtures.py +102 -0
- ksadk/harness/context_engine.py +388 -0
- ksadk/harness/context_maintenance.py +259 -0
- ksadk/harness/context_manifest.py +188 -0
- ksadk/harness/context_sections.py +397 -0
- ksadk/harness/context_tuning.py +168 -0
- ksadk/harness/diagnostic_adapters/__init__.py +1 -0
- ksadk/harness/diagnostic_adapters/contracts.py +70 -0
- ksadk/harness/diagnostic_adapters/lsp_rpc.py +210 -0
- ksadk/harness/diagnostic_adapters/native_lsp.py +286 -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 +57 -0
- ksadk/harness/engine/context_pipeline.py +1351 -0
- ksadk/harness/engine/graph_builder.py +352 -0
- ksadk/harness/engine/hooked_reasoner.py +380 -0
- ksadk/harness/engine/langgraph.py +1049 -0
- ksadk/harness/engine/mcp_disclosure.py +701 -0
- ksadk/harness/engine/phases/__init__.py +6 -0
- ksadk/harness/engine/phases/context.py +48 -0
- ksadk/harness/engine/phases/interaction.py +31 -0
- ksadk/harness/engine/phases/reason.py +552 -0
- ksadk/harness/engine/phases/tools.py +638 -0
- ksadk/harness/engine/policy_runtime.py +81 -0
- ksadk/harness/engine/postgres_checkpointer.py +386 -0
- ksadk/harness/engine/run_control_bridge.py +100 -0
- ksadk/harness/engine/run_types.py +98 -0
- ksadk/harness/engine/skill_disclosure.py +275 -0
- ksadk/harness/engine/spans.py +41 -0
- ksadk/harness/engine/steering.py +177 -0
- ksadk/harness/engine/subagents.py +360 -0
- ksadk/harness/engine/thread_ids.py +112 -0
- ksadk/harness/engine/tool_dispatch.py +249 -0
- ksadk/harness/event_tree.py +212 -0
- ksadk/harness/events.py +498 -0
- ksadk/harness/execution_policy.py +104 -0
- ksadk/harness/hooks.py +259 -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 +699 -0
- ksadk/harness/loop/tools.py +907 -0
- ksadk/harness/managed_runtime.py +1044 -0
- ksadk/harness/mcp_disclosure_contract.py +85 -0
- ksadk/harness/mcp_matrix.py +474 -0
- ksadk/harness/mcp_result_policy.py +44 -0
- ksadk/harness/mcp_runtime.py +504 -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/micro_compact.py +69 -0
- ksadk/harness/model_adapters/__init__.py +1 -0
- ksadk/harness/model_adapters/native_mcp_media.py +100 -0
- ksadk/harness/model_adapters/native_mcp_result.py +36 -0
- ksadk/harness/model_adapters/native_openai.py +703 -0
- ksadk/harness/model_capability.py +468 -0
- ksadk/harness/model_provider.py +430 -0
- ksadk/harness/multimodal.py +57 -0
- ksadk/harness/native/__init__.py +1 -0
- ksadk/harness/native/activation_contract.py +25 -0
- ksadk/harness/native/activation_recovery.py +29 -0
- ksadk/harness/native/adapters.py +291 -0
- ksadk/harness/native/artifact_contract.py +14 -0
- ksadk/harness/native/artifact_partial_read_capacity.py +171 -0
- ksadk/harness/native/artifact_read_capacity.py +182 -0
- ksadk/harness/native/artifact_read_contract.py +27 -0
- ksadk/harness/native/artifact_runtime.py +408 -0
- ksadk/harness/native/artifact_search_capacity.py +206 -0
- ksadk/harness/native/artifact_search_contract.py +40 -0
- ksadk/harness/native/artifact_single_read_capacity.py +170 -0
- ksadk/harness/native/browser_contract.py +229 -0
- ksadk/harness/native/browser_recovery.py +183 -0
- ksadk/harness/native/capabilities.py +204 -0
- ksadk/harness/native/child_approval.py +60 -0
- ksadk/harness/native/child_budget.py +136 -0
- ksadk/harness/native/child_cancellation.py +80 -0
- ksadk/harness/native/child_input.py +98 -0
- ksadk/harness/native/child_input_runtime.py +59 -0
- ksadk/harness/native/child_interruption.py +81 -0
- ksadk/harness/native/child_lifecycle.py +246 -0
- ksadk/harness/native/child_lifecycle_contract.py +91 -0
- ksadk/harness/native/child_notifications.py +75 -0
- ksadk/harness/native/child_promotion.py +66 -0
- ksadk/harness/native/command_runtime.py +99 -0
- ksadk/harness/native/completion.py +302 -0
- ksadk/harness/native/completion_text.py +116 -0
- ksadk/harness/native/context.py +358 -0
- ksadk/harness/native/context_artifact_page.py +75 -0
- ksadk/harness/native/context_compaction_projection.py +131 -0
- ksadk/harness/native/context_contributions.py +320 -0
- ksadk/harness/native/context_contributor_contract.py +133 -0
- ksadk/harness/native/context_driver.py +820 -0
- ksadk/harness/native/context_fresh_tools.py +49 -0
- ksadk/harness/native/context_history.py +272 -0
- ksadk/harness/native/context_microcompact.py +61 -0
- ksadk/harness/native/context_partial_summary.py +58 -0
- ksadk/harness/native/context_partition.py +492 -0
- ksadk/harness/native/context_pruning.py +275 -0
- ksadk/harness/native/context_reduction.py +60 -0
- ksadk/harness/native/context_replay.py +148 -0
- ksadk/harness/native/context_request_projection.py +526 -0
- ksadk/harness/native/context_runtime.py +976 -0
- ksadk/harness/native/context_runtime_contracts.py +409 -0
- ksadk/harness/native/context_search.py +112 -0
- ksadk/harness/native/context_source_fragments.py +188 -0
- ksadk/harness/native/context_source_progress.py +119 -0
- ksadk/harness/native/context_summary_planning.py +788 -0
- ksadk/harness/native/context_summary_recovery.py +105 -0
- ksadk/harness/native/delivery_review.py +331 -0
- ksadk/harness/native/delivery_review_contract.py +54 -0
- ksadk/harness/native/effect_admission.py +82 -0
- ksadk/harness/native/effect_control.py +318 -0
- ksadk/harness/native/effect_receipts.py +729 -0
- ksadk/harness/native/effect_runtime.py +303 -0
- ksadk/harness/native/effective_configuration.py +28 -0
- ksadk/harness/native/engine.py +945 -0
- ksadk/harness/native/final_output.py +34 -0
- ksadk/harness/native/final_submission.py +58 -0
- ksadk/harness/native/finalization_workspace.py +96 -0
- ksadk/harness/native/fork.py +151 -0
- ksadk/harness/native/guidance.py +91 -0
- ksadk/harness/native/history.py +381 -0
- ksadk/harness/native/hook_executor.py +205 -0
- ksadk/harness/native/hook_runtime_contract.py +282 -0
- ksadk/harness/native/interaction_observation.py +117 -0
- ksadk/harness/native/lease.py +103 -0
- ksadk/harness/native/machine.py +974 -0
- ksadk/harness/native/mcp_result_governance.py +156 -0
- ksadk/harness/native/model.py +570 -0
- ksadk/harness/native/model_feedback.py +63 -0
- ksadk/harness/native/model_input.py +30 -0
- ksadk/harness/native/model_recovery_contract.py +35 -0
- ksadk/harness/native/model_replay.py +128 -0
- ksadk/harness/native/model_request.py +133 -0
- ksadk/harness/native/model_runtime.py +196 -0
- ksadk/harness/native/model_takeover.py +419 -0
- ksadk/harness/native/model_tool_batch.py +40 -0
- ksadk/harness/native/observed_progress.py +46 -0
- ksadk/harness/native/operator_guidance.py +201 -0
- ksadk/harness/native/output_contract.py +80 -0
- ksadk/harness/native/output_recovery.py +24 -0
- ksadk/harness/native/ports.py +749 -0
- ksadk/harness/native/precompact_hook_runtime.py +171 -0
- ksadk/harness/native/replay_context.py +149 -0
- ksadk/harness/native/request_media.py +112 -0
- ksadk/harness/native/restore_contract.py +16 -0
- ksadk/harness/native/run_clock.py +120 -0
- ksadk/harness/native/state.py +436 -0
- ksadk/harness/native/steering.py +170 -0
- ksadk/harness/native/stop_hook_runtime.py +151 -0
- ksadk/harness/native/studio_admission.py +29 -0
- ksadk/harness/native/subagents.py +86 -0
- ksadk/harness/native/task_policy.py +99 -0
- ksadk/harness/native/task_progress.py +86 -0
- ksadk/harness/native/terminal_verification.py +43 -0
- ksadk/harness/native/tool_argument_feedback.py +178 -0
- ksadk/harness/native/tool_budget.py +253 -0
- ksadk/harness/native/tool_error_streak.py +89 -0
- ksadk/harness/native/tool_hook_runtime.py +343 -0
- ksadk/harness/native/tool_input_validation.py +58 -0
- ksadk/harness/native/tool_interruption.py +96 -0
- ksadk/harness/native/tool_observation.py +259 -0
- ksadk/harness/native/tool_progress.py +223 -0
- ksadk/harness/native/tool_recovery.py +25 -0
- ksadk/harness/native/tool_scheduling.py +33 -0
- ksadk/harness/native/tool_schema.py +126 -0
- ksadk/harness/native/transitions.py +151 -0
- ksadk/harness/native/turn_control.py +98 -0
- ksadk/harness/native/user_document.py +98 -0
- ksadk/harness/native/user_document_capture.py +49 -0
- ksadk/harness/native/user_input.py +87 -0
- ksadk/harness/native/verification.py +432 -0
- ksadk/harness/native/verification_binding.py +40 -0
- ksadk/harness/native/verification_runtime.py +233 -0
- ksadk/harness/native/verification_workspace.py +67 -0
- ksadk/harness/native_driver_failure.py +123 -0
- ksadk/harness/native_facade.py +977 -0
- ksadk/harness/native_factory.py +244 -0
- ksadk/harness/native_projection.py +503 -0
- ksadk/harness/native_runtime.py +621 -0
- ksadk/harness/native_shadow.py +250 -0
- ksadk/harness/native_shadow_inputs.py +146 -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/progress_adapters/__init__.py +5 -0
- ksadk/harness/progress_adapters/native_todo.py +75 -0
- ksadk/harness/prompt_cache.py +132 -0
- ksadk/harness/public_activity.py +213 -0
- ksadk/harness/public_output.py +30 -0
- ksadk/harness/public_summary.py +36 -0
- ksadk/harness/readiness.py +249 -0
- ksadk/harness/reasoner.py +779 -17
- ksadk/harness/release_readiness.py +140 -0
- ksadk/harness/resource_ref.py +69 -0
- ksadk/harness/rpc.py +200 -0
- ksadk/harness/run_control.py +773 -0
- ksadk/harness/runtime.py +157 -113
- ksadk/harness/runtime_capabilities.py +228 -0
- ksadk/harness/runtime_server.py +514 -0
- ksadk/harness/sandbox_adapters.py +739 -0
- ksadk/harness/sandbox_backend.py +733 -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/sdk.py +153 -0
- ksadk/harness/session_store.py +589 -0
- ksadk/harness/skill_adapters/__init__.py +1 -0
- ksadk/harness/skill_adapters/native_bundle.py +148 -0
- ksadk/harness/skill_adapters/native_disclosure.py +306 -0
- ksadk/harness/skill_composition.py +212 -0
- ksadk/harness/skill_feedback.py +123 -0
- ksadk/harness/skill_intent.py +47 -0
- ksadk/harness/skill_matrix.py +233 -0
- ksadk/harness/skill_runtime.py +317 -0
- ksadk/harness/spec.py +342 -0
- ksadk/harness/state.py +155 -0
- ksadk/harness/stores/__init__.py +14 -0
- ksadk/harness/stores/native_command_settlement.py +65 -0
- ksadk/harness/stores/native_contract.py +311 -0
- ksadk/harness/stores/native_memory.py +326 -0
- ksadk/harness/stores/native_memory_archive.py +70 -0
- ksadk/harness/stores/native_migration_cli.py +91 -0
- ksadk/harness/stores/native_outbox.py +56 -0
- ksadk/harness/stores/native_sqlite.py +782 -0
- ksadk/harness/stores/native_sqlite_audit.py +29 -0
- ksadk/harness/stores/native_sqlite_migration.py +252 -0
- ksadk/harness/strategies.py +149 -0
- ksadk/harness/subagent.py +263 -0
- ksadk/harness/subagent_adapters/checkpoint_recovery.py +120 -0
- ksadk/harness/subagent_adapters/native_background_child.py +803 -0
- ksadk/harness/subagent_adapters/native_child.py +819 -0
- ksadk/harness/subagent_adapters/native_child_approval.py +128 -0
- ksadk/harness/subagent_adapters/native_child_continuation.py +51 -0
- ksadk/harness/subagent_adapters/native_child_result.py +392 -0
- ksadk/harness/subagent_adapters/prepared_recovery.py +120 -0
- ksadk/harness/tool_display.py +75 -0
- ksadk/harness/tool_display_contract.py +134 -0
- ksadk/harness/tool_output.py +141 -0
- ksadk/harness/tool_policy.py +134 -0
- ksadk/harness/tool_receipts.py +96 -0
- ksadk/harness/tool_reliability.py +81 -0
- ksadk/harness/tool_result_policy.py +216 -0
- ksadk/harness/tools.py +52 -0
- ksadk/harness/user_errors.py +69 -0
- ksadk/harness/working_context.py +81 -0
- ksadk/harness/working_context_patch.py +99 -0
- ksadk/harness/workspace_adapters/__init__.py +6 -0
- ksadk/harness/workspace_adapters/native_directory.py +180 -0
- ksadk/harness/workspace_adapters/native_git.py +208 -0
- ksadk/harness/workspace_adapters/native_isolation.py +350 -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 +9 -2
- ksadk/kernel/__init__.py +10 -0
- ksadk/kernel/approval_presentation.py +91 -0
- ksadk/kernel/authorization.py +1 -1
- ksadk/kernel/bootstrap.py +220 -252
- ksadk/kernel/contract_fingerprints.py +45 -1
- ksadk/kernel/contracts.py +30 -0
- ksadk/kernel/control.py +180 -29
- ksadk/kernel/execution_grants.py +428 -0
- ksadk/kernel/execution_grants_memory.py +252 -0
- ksadk/kernel/execution_grants_postgres.py +395 -0
- ksadk/kernel/execution_grants_sqlite.py +435 -0
- ksadk/kernel/execution_host_ingress.py +1071 -0
- ksadk/kernel/history_projection.py +120 -0
- ksadk/kernel/ingress.py +139 -226
- ksadk/kernel/ingress_bootstrap.py +268 -0
- ksadk/kernel/legacy_history.py +179 -0
- ksadk/kernel/mapping.py +1 -1
- ksadk/kernel/memory_store.py +61 -58
- ksadk/kernel/memory_store_projection.py +63 -0
- ksadk/kernel/postgres_event_log.py +181 -0
- ksadk/kernel/postgres_store.py +230 -231
- ksadk/kernel/readiness.py +125 -0
- ksadk/kernel/recovery.py +166 -16
- ksadk/kernel/recovery_projection.py +124 -0
- ksadk/kernel/runtime_checkpoint.py +34 -0
- ksadk/kernel/sql/001_agent_kernel.sql +28 -0
- ksadk/kernel/sqlite_schema.py +100 -0
- ksadk/kernel/sqlite_store.py +410 -200
- ksadk/kernel/state.py +2 -3
- ksadk/kernel/store.py +104 -5
- ksadk/kernel/teams_artifact_tools.py +392 -0
- ksadk/kernel/teams_effects.py +851 -0
- ksadk/kernel/teams_execution_context.py +408 -0
- ksadk/kernel/teams_host_http.py +237 -0
- ksadk/kernel/teams_material_transport.py +245 -0
- ksadk/kernel/teams_materials.py +318 -0
- ksadk/kernel/teams_runtime_bootstrap.py +604 -0
- ksadk/kernel/teams_tool_runtime.py +273 -0
- ksadk/kernel/teams_workspace.py +259 -0
- ksadk/kernel/worker.py +369 -340
- ksadk/kernel/worker_controls.py +454 -0
- ksadk/kernel/worker_history.py +72 -0
- ksadk/kernel/worker_identity.py +74 -0
- ksadk/kernel/worker_interactions.py +197 -0
- ksadk/knowledge_base/client.py +15 -1
- ksadk/managed_runtime.py +29 -2
- ksadk/memory/adk/backends/http_ltm_backend.py +2 -1
- ksadk/memory/adk/backends/sdk_ltm_backend.py +15 -1
- ksadk/memory/adk/bounded_database_session_service.py +232 -0
- ksadk/memory/adk/resilient_session_service.py +115 -15
- ksadk/memory/adk/short_term_memory.py +8 -9
- ksadk/memory/coordinator.py +22 -6
- ksadk/memory/extraction.py +159 -7
- ksadk/memory/models.py +77 -1
- ksadk/memory/provider_resolver.py +5 -0
- ksadk/memory/providers/local_candidates.py +183 -0
- ksadk/memory/providers/local_postgres.py +200 -0
- ksadk/memory/providers/local_sqlite.py +280 -67
- ksadk/memory/resolved_policy.py +12 -7
- ksadk/memory/retrieval.py +189 -0
- ksadk/memory/store_adapter.py +150 -0
- ksadk/model_gateway/__init__.py +29 -0
- ksadk/model_gateway/client.py +253 -0
- ksadk/model_gateway/events.py +113 -0
- ksadk/model_gateway/matrix.py +297 -0
- ksadk/model_policy.py +2 -2
- ksadk/model_proxy/compat.py +670 -0
- ksadk/model_proxy/detect.py +254 -0
- ksadk/model_proxy/server.py +14 -9
- ksadk/model_proxy/transform.py +72 -6
- ksadk/plugins/__init__.py +1 -1
- ksadk/plugins/bridges/dsh.py +29 -20
- ksadk/plugins/bridges/dsh_profile_manifest.py +36 -0
- ksadk/plugins/builtin_resources.py +199 -0
- ksadk/plugins/builtins.py +417 -185
- ksadk/plugins/companion_artifacts.py +83 -0
- ksadk/plugins/companions.py +368 -0
- ksadk/plugins/context_contributor.py +15 -4
- ksadk/plugins/contracts.py +1 -1
- ksadk/plugins/dsh_channels.py +156 -0
- ksadk/plugins/dsh_dependency_policy.py +41 -0
- ksadk/plugins/dsh_home.py +140 -0
- ksadk/plugins/dsh_teams.py +105 -0
- ksadk/plugins/dsh_toolchain.py +92 -21
- ksadk/plugins/execution_host.py +107 -0
- ksadk/plugins/host.py +73 -5
- ksadk/plugins/kernel_adapter.py +44 -1
- ksadk/plugins/memory_provider.py +180 -0
- ksadk/plugins/providers/_process_group.py +50 -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/index.mjs +24 -2
- 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 +52 -40
- ksadk/plugins/providers/codex_native.py +20 -0
- ksadk/plugins/providers/codex_skills.py +46 -0
- ksadk/plugins/providers/dsh_capabilities.py +49 -143
- ksadk/plugins/providers/dsh_connector_lease.py +225 -0
- ksadk/plugins/providers/dsh_mcp.py +163 -1
- ksadk/plugins/providers/harness.py +413 -52
- ksadk/plugins/providers/harness_context.py +61 -0
- ksadk/plugins/providers/harness_contributions.py +241 -0
- ksadk/plugins/providers/harness_delegation.py +670 -0
- ksadk/plugins/providers/harness_hooks.py +121 -0
- ksadk/plugins/providers/harness_managed.py +550 -0
- ksadk/plugins/providers/harness_tools.py +455 -0
- ksadk/plugins/providers/legacy_catalog.py +1 -1
- ksadk/plugins/providers/mcp_projection.py +100 -3
- ksadk/plugins/providers/platform_resources.py +16 -6
- 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 +540 -0
- ksadk/plugins/teams/artifacts.py +60 -0
- ksadk/plugins/teams/build_artifacts.py +460 -0
- ksadk/plugins/teams/cloud_contract_fingerprints.py +22 -0
- ksadk/plugins/teams/cloud_contracts.py +928 -0
- ksadk/plugins/teams/cloud_permits.py +250 -0
- ksadk/plugins/teams/context.py +96 -0
- ksadk/plugins/teams/contracts.py +136 -0
- ksadk/plugins/teams/domain.py +1480 -0
- ksadk/plugins/teams/domain_values.py +24 -0
- ksadk/plugins/teams/effect_contracts.py +255 -0
- ksadk/plugins/teams/errors.py +13 -0
- ksadk/plugins/teams/execution_projection.py +255 -0
- ksadk/plugins/teams/leader_decisions.py +106 -0
- ksadk/plugins/teams/migration.py +311 -0
- ksadk/plugins/teams/migration_cli.py +322 -0
- ksadk/plugins/teams/postgres_store.py +352 -0
- ksadk/plugins/teams/release_contracts.py +60 -0
- ksadk/plugins/teams/runtime.py +853 -0
- ksadk/plugins/teams/source_projection.py +84 -0
- ksadk/plugins/teams/store.py +519 -0
- ksadk/plugins/teams/task_decisions.py +436 -0
- ksadk/plugins/teams/tool_service.py +152 -0
- ksadk/plugins/teams/transport.py +96 -0
- ksadk/plugins/teams/workspaces.py +255 -0
- ksadk/resource_runtime/skill_runtime.py +3 -0
- ksadk/resource_runtime/socket_server.py +11 -0
- ksadk/resource_runtime/worker.py +28 -4
- ksadk/runners/_adk_a2a_stream.py +122 -0
- ksadk/runners/_adk_canonical_stream.py +474 -0
- ksadk/runners/_langgraph_canonical_streams.py +527 -0
- ksadk/runners/_langgraph_runner_streams.py +83 -401
- ksadk/runners/_langgraph_state_reader.py +106 -0
- ksadk/runners/_langgraph_tool_projection.py +86 -0
- ksadk/runners/_langgraph_tools_transformer.py +27 -0
- ksadk/runners/_session_identity.py +285 -0
- ksadk/runners/adk_runner.py +220 -350
- ksadk/runners/base_runner.py +6 -5
- ksadk/runners/langgraph_runner.py +208 -195
- ksadk/runners/patch_langchain.py +47 -0
- ksadk/runners/usage_accumulator.py +11 -3
- ksadk/runners/utils/loader.py +28 -14
- ksadk/runtime/_runner_adapter/a2ui_surface.py +145 -0
- ksadk/runtime/_runner_adapter/gateway_approvals.py +93 -0
- ksadk/runtime/_runner_adapter/stream_mapping.py +134 -129
- ksadk/runtime/adapter.py +40 -3
- ksadk/runtime/conversation_execution.py +29 -3
- ksadk/runtime/executor.py +105 -7
- ksadk/runtime/factory.py +45 -3
- ksadk/runtime/framework_adapters.py +184 -10
- ksadk/runtime/hosted_finalizer.py +4 -6
- ksadk/runtime/launch.py +2 -0
- ksadk/runtime/preprocessing.py +11 -3
- ksadk/runtime/runner_adapter.py +160 -21
- ksadk/runtime/skill_eval_result.py +36 -0
- ksadk/runtime/timing.py +46 -0
- ksadk/runtime/usage.py +49 -18
- ksadk/runtime_context.py +105 -1
- ksadk/sandbox/backends/e2b.py +272 -24
- ksadk/sandbox/backends/local_process.py +73 -39
- ksadk/sandbox/base.py +62 -1
- ksadk/sandbox/diagnostics.py +82 -0
- ksadk/sandbox/e2b_connection.py +9 -1
- ksadk/sandbox/local_controls.py +776 -0
- ksadk/sandbox/local_launcher.py +124 -0
- ksadk/scheduler/dispatcher.py +1 -1
- ksadk/server/factory.py +178 -25
- ksadk/server/history_deadline.py +158 -0
- ksadk/server/history_page_cache.py +129 -0
- ksadk/server/invocation_identity.py +118 -0
- ksadk/server/routes/checkpoint_audit.py +88 -0
- ksadk/server/routes/checkpoint_listing.py +294 -0
- ksadk/server/routes/checkpoint_resolution.py +73 -20
- ksadk/server/routes/common.py +32 -3
- ksadk/server/routes/control.py +112 -9
- ksadk/server/routes/dependencies.py +2 -1
- ksadk/server/routes/display_projection.py +154 -0
- ksadk/server/routes/kernel_ingress.py +26 -3
- ksadk/server/routes/misc.py +331 -33
- ksadk/server/routes/models.py +28 -4
- ksadk/server/routes/openai_compat.py +82 -13
- ksadk/server/routes/projection.py +159 -216
- ksadk/server/routes/run.py +112 -37
- ksadk/server/routes/sessions.py +493 -358
- ksadk/server/routes/streaming.py +68 -15
- ksadk/server/routes/tool_receipt_claim_routes.py +107 -0
- ksadk/server/routes/workspace.py +135 -23
- ksadk/server/static/assets/{ArtifactsPanel-CGbWlMNh.js → ArtifactsPanel-CILaW-fC.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-b4C7upmO.js → CodeBlock-BVrNVtJC.js} +10 -7
- ksadk/server/static/assets/MathMessageMarkdown-Dp7c4wWD.js +8 -0
- ksadk/server/static/assets/{MermaidBlock-BEBN4Ksz.js → MermaidBlock-Dxop8Rd7.js} +9 -9
- ksadk/server/static/assets/{NativeTerminalPanel-zvL-WpAn.js → NativeTerminalPanel-Cjjz8B30.js} +1 -1
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-BYafW7Za.js → abnfDiagram-VCTEODGH-ckWDmOzw.js} +1 -1
- ksadk/server/static/assets/{arc-bTohInsS.js → arc-DqxJede-.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-pn_DuLy6.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-Ch5Lbzsi.js → architectureDiagram-5GKGNRK7-SEQA4bVi.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-kqF4MDOG.js → blockDiagram-NRAW4CY4-pM0B-6NJ.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-8uSRIODv.js → c4Diagram-UCG6FXSJ-m2tuCNVq.js} +1 -1
- ksadk/server/static/assets/channel-fySsnkft.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-BheGxKRQ.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-DkhehZDr.js → chunk-5VM5RSS4-GJHDr9Ww.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-BdXhtPe9.js → chunk-F27PBJKO-CbAN45AV.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-DPTpvpwi.js → chunk-G27WJ6UU-D5ngbbzF.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-Pqoh38el.js → chunk-JWPE2WC7-Cc5IwuYC.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-DeU00qC-.js → chunk-LCL6LL3I-CprgDDdJ.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-CzxScFkr.js → chunk-POPQ4Y6H-CDZhSy82.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-DpqMx-ux.js → chunk-RHFEMEQ7-CZchUNro.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-C6t0SypQ.js → chunk-SVP7TREG-BVruqk6T.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-DVaeafZk.js → chunk-XXDRQBXY-4ld9SxPN.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DSfLtNYm.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DSfLtNYm.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-Bf9D3tzJ.js → cose-bilkent-JH36ORCC-Dmyyk_Vp.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-PFWIGtvA.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-B9cY3iTz.js → cynefinDiagram-5FMLGOSQ-BIyq3EJb.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-CSwlx3CB.js → dagre-3AP2YEHR-eBw08Qdk.js} +1 -1
- ksadk/server/static/assets/{dagre-UBpgon5q.js → dagre-DfvnEf45.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-C9akhN9a.js → diagram-S7CK7UJ4-CUSrE3Mg.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-CgedhTPI.js → diagram-UQ7AKVKN-Dq5Zw2gy.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-Cjucz5BY.js → diagram-VSXAHHWV-DyUHfNwT.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-Dd4Vleyn.js → diagram-VX7I27RA-CREmM89O.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-CZ2jGtYW.js → diagram-Z3DM3KII-Dw9zhHUK.js} +1 -1
- ksadk/server/static/assets/{dist-Bj730Ib4.js → dist-0uJ4tdx6.js} +1 -1
- ksadk/server/static/assets/{dist-BnaTiyzN.js → dist-AEv-vXf-.js} +1 -1
- ksadk/server/static/assets/{dist-BgV_owcB.js → dist-B49GzZDb.js} +1 -1
- ksadk/server/static/assets/{dist-D_ctSS2i.js → dist-B8Myiet9.js} +1 -1
- ksadk/server/static/assets/{dist-ufY3F5p6.js → dist-BBsYarrI.js} +2 -2
- ksadk/server/static/assets/{dist-ClYUxfeK.js → dist-BQMrUwdI.js} +1 -1
- ksadk/server/static/assets/{dist-CFzsn6BG.js → dist-BX_-FENW.js} +1 -1
- ksadk/server/static/assets/{dist-B3FR1SKK.js → dist-CD4L6ymH.js} +1 -1
- ksadk/server/static/assets/{dist-Cf125P_m.js → dist-CHpW1BHj.js} +1 -1
- ksadk/server/static/assets/{dist-DVCOWtha.js → dist-CVPau3tn.js} +1 -1
- ksadk/server/static/assets/{dist-DFD6Qa6T.js → dist-C_qdxcSH.js} +1 -1
- ksadk/server/static/assets/{dist-BIr4DSRq.js → dist-Co68Apq4.js} +1 -1
- ksadk/server/static/assets/{dist-DiixqL0J.js → dist-Cp2PaOMY.js} +1 -1
- ksadk/server/static/assets/{dist-fBO2v5Kt.js → dist-CuR5Bgme.js} +1 -1
- ksadk/server/static/assets/{dist-DoVSwoDb.js → dist-DDSyLEOX.js} +1 -1
- ksadk/server/static/assets/{dist-C5_ZAZsG.js → dist-DUxO0R99.js} +1 -1
- ksadk/server/static/assets/{dist-C1NMAY5a.js → dist-QzbGrED_.js} +1 -1
- ksadk/server/static/assets/dist-bupkyEBZ.js +1 -0
- ksadk/server/static/assets/{dist-DvFK7p5S.js → dist-cxTGfdqx.js} +1 -1
- ksadk/server/static/assets/{dist-CB9iJrvg.js → dist-hL5p1til.js} +1 -1
- ksadk/server/static/assets/{dist-btbmmX5O.js → dist-lOy23y43.js} +1 -1
- ksadk/server/static/assets/{dist-QfkEHOlb.js → dist-pq-nD33R.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-Ci8NqqZu.js → ebnfDiagram-PWID7BFC-BS5LdNoR.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-CCIOhLZG.js → erDiagram-SSCWMZ5O-Bv1QtiY-.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-DsM4upQX.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-D5NA16k9.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-Cp_r9Hb6.js → ganttDiagram-EL5Y4UJY-musi-e0G.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-DUCVz-ih.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-Dlhc8Wr8.js → gitGraphDiagram-WWUBYQGX-DH37EGkG.js} +1 -1
- ksadk/server/static/assets/index-CZdkAvsv.js +244 -0
- ksadk/server/static/assets/index-CvXdHgF3.css +2 -0
- ksadk/server/static/assets/info-A6RAGUB7-rw0ZNHZp.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-CO0rRTRA.js → infoDiagram-RXCK75RN-C1kEtv2y.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-CHiaedSS.js → ishikawaDiagram-5VMMS53U-BCNPyMka.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL-CHcCIB09.js → journeyDiagram-EYS64GPL--cDbKnjP.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-CJ_ebBZf.js → kanban-definition-3QL26DDD-R1rAVw2f.js} +1 -1
- ksadk/server/static/assets/{katex-B4weu383.js → katex-BT-X-V7U.js} +1 -1
- ksadk/server/static/assets/{linear-V-MgYHW1.js → linear-DTR631iG.js} +1 -1
- ksadk/server/static/assets/{mermaid-parser.core-CBijEX_c.js → mermaid-parser.core-DfFzJhX8.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-Bc-pQvpp.js → mindmap-definition-FBJOCRG2-D4by_rmk.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-Ca4Hvki9.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-D7genGLl.js → pegDiagram-XKGWAZYB-xWXPEh0c.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-hwiz6fbw.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-Bxj32zwD.js → pieDiagram-E7YTZNPT-BudBDlCI.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-BURv2mGh.js → quadrantDiagram-AXDQQJYC-DXZ0PCJF.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BR1oZXLM.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-DfgEISfX.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-CWOC3rdk.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CiRvHCLY.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-DSDDyJ2f.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-CCsh3avW.js → railroadDiagram-O6MQD6OU-BdAYRYB8.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-_FRRBKEd.js → requirementDiagram-EFPCY7ZU-CBBmaL70.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-C-gr2o9M.js → sankeyDiagram-P5KCCOFB-Doc3rdwp.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-D97NmfKg.js → sequenceDiagram-WJ2MYXX4-0J8R8hWW.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-DjrPC5FX.js → sizeCapture-X5ZJPWSS-CfFLlWsK.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-DzMNg1hh.js → stateDiagram-HBIQ2CUA-jBwkjtTy.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Cw1fPb5w.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-Cssf_CsU.js → swimlanes-XN3QIQJK-B0WxTQf8.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-Cc3JMBAF.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-BWTHzyS1.js → timeline-definition-24CTP7MA-BfCT_75A.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-C05SJHxo.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-BqNLAhc3.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-BSKgJsmR.js → vennDiagram-4TSXK5OY-9gX1VMDC.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-DokNktqB.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-eflHNoaZ.js → wardleyDiagram-VM6X3IG4-sEs_BP6O.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-eYqrQ-v4.js → xychartDiagram-S5SC5T6Z-Ll4jvUN9.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/server/terminal_sessions.py +34 -2
- ksadk/sessions/__init__.py +8 -1
- ksadk/sessions/_checkpoint_resume_audit.py +44 -0
- ksadk/sessions/_in_memory_query.py +112 -0
- ksadk/sessions/_local_service_sync.py +157 -156
- ksadk/sessions/_local_state_sync.py +152 -0
- ksadk/sessions/_local_tables.py +2 -0
- ksadk/sessions/_postgres_checkpoint_read.py +323 -0
- ksadk/sessions/_postgres_checkpoint_stats.py +330 -0
- ksadk/sessions/_postgres_history_read.py +678 -0
- ksadk/sessions/_postgres_schema.py +44 -2
- ksadk/sessions/_postgres_tables.py +2 -0
- ksadk/sessions/_postgres_tool_receipts.py +169 -0
- ksadk/sessions/_resilient_read.py +630 -0
- ksadk/sessions/_tool_receipt_sync.py +119 -0
- ksadk/sessions/agent_identity.py +16 -0
- ksadk/sessions/base.py +278 -0
- ksadk/sessions/db_budget.py +332 -0
- ksadk/sessions/errors.py +12 -0
- ksadk/sessions/history_budget.py +36 -0
- ksadk/sessions/history_identity.py +27 -0
- ksadk/sessions/in_memory.py +376 -113
- ksadk/sessions/invocation_identity.py +235 -0
- ksadk/sessions/local_service.py +345 -0
- ksadk/sessions/postgres_service.py +515 -549
- ksadk/sessions/resilience.py +21 -14
- ksadk/sessions/resilient.py +611 -504
- ksadk/skills/__init__.py +26 -0
- ksadk/skills/events.py +464 -0
- ksadk/skills/loader.py +44 -2
- 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 +400 -56
- 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/service_client.py +6 -1
- ksadk/skills/tool_defs.py +108 -3
- ksadk/studio/a2a_bindings.py +407 -0
- ksadk/studio/a2a_orchestration.py +178 -0
- ksadk/studio/active_run_output.py +92 -0
- ksadk/studio/activity_records.py +542 -0
- ksadk/studio/agent_configuration.py +173 -0
- ksadk/studio/api.py +784 -419
- ksadk/studio/api_a2a_routes.py +93 -0
- ksadk/studio/api_catalog_routes.py +13 -0
- ksadk/studio/api_cloud_chat_routes.py +382 -0
- ksadk/studio/api_contracts.py +31 -2
- ksadk/studio/api_plugin_routes.py +39 -12
- ksadk/studio/api_resource_connections.py +79 -41
- ksadk/studio/attachment_store.py +14 -2
- ksadk/studio/authoring.py +12 -6
- ksadk/studio/authoring_coordinator.py +4 -2
- ksadk/studio/build_resolution.py +117 -0
- ksadk/studio/build_singleflight.py +37 -0
- ksadk/studio/builder.py +32 -2
- ksadk/studio/capabilities.py +31 -9
- ksadk/studio/channel_connections.py +333 -0
- ksadk/studio/cloud.py +113 -387
- ksadk/studio/cloud_gateways.py +424 -0
- ksadk/studio/cloud_shared_web.py +82 -2
- ksadk/studio/codex_agent_service.py +19 -2
- ksadk/studio/codex_builder.py +1 -1
- ksadk/studio/codex_manifest.py +5 -1
- ksadk/studio/codex_provider_build.py +65 -0
- ksadk/studio/codex_run.py +6 -1
- ksadk/studio/compiler.py +112 -6
- ksadk/studio/configuration.py +182 -0
- ksadk/studio/contract_base.py +19 -0
- ksadk/studio/contracts.py +260 -202
- ksadk/studio/dsh_application.py +183 -27
- ksadk/studio/dsh_capability_service.py +302 -189
- ksadk/studio/dsh_lifecycle.py +58 -0
- ksadk/studio/dsh_mcp_transport.py +191 -0
- ksadk/studio/dsh_provider_registration.py +55 -16
- ksadk/studio/entry.py +53 -0
- ksadk/studio/event_store.py +53 -5
- ksadk/studio/execution_host.py +598 -0
- ksadk/studio/framework_run.py +50 -10
- ksadk/studio/hosted_kernel.py +1 -1
- ksadk/studio/interaction_submission.py +265 -0
- ksadk/studio/kernel_registry.py +429 -0
- ksadk/studio/kernel_sqlite_migration.py +181 -0
- ksadk/studio/lifecycle_status.py +43 -0
- ksadk/studio/model_buffered_wire.py +227 -0
- ksadk/studio/model_chat_tools.py +143 -0
- ksadk/studio/model_client.py +1939 -345
- ksadk/studio/model_content_stream.py +129 -0
- ksadk/studio/model_credentials.py +196 -0
- ksadk/studio/model_profile_service.py +89 -40
- ksadk/studio/model_request_projection.py +284 -0
- ksadk/studio/model_responses_content.py +296 -0
- ksadk/studio/model_usage.py +109 -0
- ksadk/studio/model_wire_failure.py +110 -0
- ksadk/studio/model_wire_identity.py +138 -0
- ksadk/studio/model_wire_snapshot.py +45 -0
- ksadk/studio/model_wire_tools.py +283 -0
- ksadk/studio/native_acceptance.py +68 -0
- ksadk/studio/native_approval.py +111 -0
- ksadk/studio/native_browser_port.py +861 -0
- ksadk/studio/native_child_mcp.py +87 -0
- ksadk/studio/native_child_publication.py +68 -0
- ksadk/studio/native_child_skills.py +72 -0
- ksadk/studio/native_child_workspace.py +176 -0
- ksadk/studio/native_command_policy.py +53 -0
- ksadk/studio/native_context_port.py +326 -0
- ksadk/studio/native_context_registration.py +54 -0
- ksadk/studio/native_document_input.py +88 -0
- ksadk/studio/native_documents.py +172 -0
- ksadk/studio/native_final_shape.py +852 -0
- ksadk/studio/native_gateway_stream.py +69 -0
- ksadk/studio/native_hook_port.py +145 -0
- ksadk/studio/native_hook_registration.py +70 -0
- ksadk/studio/native_inventory_disclosure.py +223 -0
- ksadk/studio/native_kernel_admission.py +84 -0
- ksadk/studio/native_language_diagnostics.py +320 -0
- ksadk/studio/native_mcp_disclosure.py +198 -0
- ksadk/studio/native_mcp_tool_port.py +219 -0
- ksadk/studio/native_memory_acceptance.py +362 -0
- ksadk/studio/native_memory_context.py +266 -0
- ksadk/studio/native_memory_flush.py +174 -0
- ksadk/studio/native_memory_sources.py +80 -0
- ksadk/studio/native_memory_tool_port.py +360 -0
- ksadk/studio/native_memory_turn.py +183 -0
- ksadk/studio/native_model_port.py +765 -0
- ksadk/studio/native_model_recovery.py +126 -0
- ksadk/studio/native_options.py +75 -0
- ksadk/studio/native_output_fields.py +58 -0
- ksadk/studio/native_planning.py +156 -0
- ksadk/studio/native_product.py +988 -0
- ksadk/studio/native_read_budget.py +426 -0
- ksadk/studio/native_recovery.py +171 -0
- ksadk/studio/native_scope.py +35 -0
- ksadk/studio/native_session_context_port.py +141 -0
- ksadk/studio/native_session_engine.py +14 -0
- ksadk/studio/native_skill_source.py +74 -0
- ksadk/studio/native_subagent_port.py +700 -0
- ksadk/studio/native_terminal_recovery.py +95 -0
- ksadk/studio/native_test_action.py +610 -0
- ksadk/studio/native_tool_port.py +477 -0
- ksadk/studio/native_user_input.py +60 -0
- ksadk/studio/native_verification_presentation.py +65 -0
- ksadk/studio/native_workspace_diagnostics.py +183 -0
- ksadk/studio/native_workspace_port.py +43 -0
- ksadk/studio/operations.py +34 -9
- ksadk/studio/plugin_composition.py +39 -12
- ksadk/studio/plugin_kernel_adapter.py +89 -0
- ksadk/studio/plugin_lifecycle.py +80 -0
- ksadk/studio/plugin_native_activation.py +163 -0
- ksadk/studio/plugin_runtime.py +832 -99
- ksadk/studio/plugin_runtime_admission.py +57 -0
- ksadk/studio/presentation.py +92 -0
- ksadk/studio/provider_recovery.py +59 -0
- ksadk/studio/public_output_store.py +69 -0
- ksadk/studio/recovery_page.py +70 -0
- ksadk/studio/resource_authority.py +69 -34
- ksadk/studio/resource_catalog.py +14 -12
- ksadk/studio/run_activity.py +848 -0
- ksadk/studio/run_controls.py +185 -0
- ksadk/studio/run_documents.py +127 -0
- ksadk/studio/run_service.py +1220 -335
- ksadk/studio/run_submission_receipts.py +68 -0
- ksadk/studio/runtime_catalog.py +73 -11
- ksadk/studio/runtime_prewarm.py +22 -0
- ksadk/studio/runtime_source.py +1 -1
- ksadk/studio/scheduler_assistant.py +4 -1
- ksadk/studio/scheduler_runtime.py +32 -289
- ksadk/studio/service.py +615 -246
- ksadk/studio/service_settings.py +229 -0
- ksadk/studio/shared_web.py +518 -181
- ksadk/studio/shared_web_response_events.py +180 -0
- ksadk/studio/shared_web_run_state.py +133 -0
- ksadk/studio/skill_discovery.py +305 -3
- ksadk/studio/static/assets/ChannelsPage-xX5HlMId.js +8 -0
- ksadk/studio/static/assets/CodeBlock-DMIf4h33-CkufcPYo.js +44 -0
- ksadk/studio/static/assets/ExecutionTree-v3HexvPo-Bk8wzGSy.js +1 -0
- ksadk/studio/static/assets/MathMessageMarkdown-BesSeCYl-DYG1Wzbx.js +8 -0
- ksadk/studio/static/assets/MermaidBlock-H_0qzQDf-BdXtxug_.js +11 -0
- ksadk/studio/static/assets/MessageMarkdown-CwMTvgFj-BeyLyQHu.js +59 -0
- ksadk/studio/static/assets/PrismRenderer-5pK6tUdb.js +3 -0
- ksadk/studio/static/assets/TeamsPage-CCaaGaVp.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-C7DNDik2.css +2 -0
- ksadk/studio/static/assets/index-Cy68gTlH.js +265 -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 +166 -0
- ksadk/studio/teams_installation.py +217 -0
- ksadk/studio/teams_node.py +549 -0
- ksadk/studio/teams_node_factory.py +558 -0
- ksadk/studio/teams_node_runner.py +72 -0
- ksadk/studio/teams_node_v1.py +935 -0
- ksadk/studio/teams_remote.py +496 -0
- ksadk/studio/templates.py +41 -19
- ksadk/studio/validator.py +13 -0
- ksadk/studio/workspace.py +19 -4
- ksadk/studio/workspace_plugins.py +138 -0
- ksadk/studio/workspace_registry.py +286 -0
- ksadk/tools/a2a_policy.py +5 -0
- ksadk/tools/artifact_observation.py +53 -0
- ksadk/tools/captured_source_artifact.py +68 -0
- ksadk/tools/schema.py +34 -0
- ksadk/toolsets/__init__.py +93 -88
- ksadk/toolsets/a2a.py +89 -89
- ksadk/toolsets/sandbox.py +377 -6
- ksadk/toolsets/skill_management.py +315 -0
- ksadk/toolsets/skills.py +446 -378
- ksadk/toolsets/tool_selection.py +94 -0
- ksadk/toolsets/workspace.py +344 -326
- ksadk/toolsets/workspace_editing.py +291 -0
- ksadk/toolsets/workspace_identity.py +15 -0
- ksadk/toolsets/workspace_model_observation.py +104 -0
- ksadk/toolsets/workspace_mutation.py +75 -0
- ksadk/toolsets/workspace_read_budget.py +216 -0
- ksadk/toolsets/workspace_search.py +192 -0
- ksadk/toolsets/workspace_search_process.py +129 -0
- ksadk/toolsets/workspace_state.py +6 -0
- ksadk/version.py +1 -1
- ksadk_runtime_common/http_headers.py +18 -0
- 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 +28 -14
- agentengine_sdk_python-0.8.4.dist-info/RECORD +0 -1070
- 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.6.dist-info}/WHEEL +0 -0
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.6.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.6.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.4.dist-info → agentengine_sdk_python-0.8.6.dist-info}/top_level.txt +0 -0
- /ksadk/studio/static/assets/{MathMessageMarkdown-CBcDrAw--BEOyPC3w.css → MathMessageMarkdown-BesSeCYl-BEOyPC3w.css} +0 -0
|
@@ -0,0 +1,1049 @@
|
|
|
1
|
+
"""ManagedLangGraphEngine —— 默认执行引擎(plan §7 / Kernel)。
|
|
2
|
+
|
|
3
|
+
实现 §7.1 默认 Agent Loop 的 Kernel 子集:prepare_context -> reason ->
|
|
4
|
+
tool_calls -> final,reason 自环。LangGraph 类型不越出本模块
|
|
5
|
+
(tests/architecture/test_harness_contract.py 守卫)。
|
|
6
|
+
|
|
7
|
+
Kernel 能力范围(诚实声明):
|
|
8
|
+
- Cancel:支持(终止语义,不伪装 Pause);
|
|
9
|
+
- Interrupt/Resume:支持(approval 通道,resume 携带 payload 重放);
|
|
10
|
+
- Checkpoint:LangGraph Checkpointer 注入(内存/SQLite),thread_id 走
|
|
11
|
+
租户复合编码(plan §6.2.2);
|
|
12
|
+
- Context 压缩:Release 交付,本引擎留 policy 读取口。
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import asyncio
|
|
18
|
+
import time
|
|
19
|
+
import uuid
|
|
20
|
+
from typing import Any, AsyncIterator, Callable
|
|
21
|
+
|
|
22
|
+
from langgraph.checkpoint.base import BaseCheckpointSaver
|
|
23
|
+
from langgraph.errors import GraphInterrupt
|
|
24
|
+
from langgraph.types import Command
|
|
25
|
+
|
|
26
|
+
from ksadk.harness.engine import budgets, hooked_reasoner
|
|
27
|
+
from ksadk.harness.engine.base import (
|
|
28
|
+
CompiledHarness,
|
|
29
|
+
EngineCapability,
|
|
30
|
+
EngineCapabilityMatrix,
|
|
31
|
+
ExecutionEngineError,
|
|
32
|
+
)
|
|
33
|
+
from ksadk.harness.engine.context_pipeline import EngineContextPipeline
|
|
34
|
+
from ksadk.harness.engine.hooked_reasoner import bind_hooked_reasoner, clear_hook_run
|
|
35
|
+
from ksadk.harness.engine.mcp_disclosure import (
|
|
36
|
+
McpDisclosureBridge,
|
|
37
|
+
McpDisclosureCursors,
|
|
38
|
+
)
|
|
39
|
+
from ksadk.harness.engine.policy_runtime import configure_run, revalidate_policy
|
|
40
|
+
from ksadk.harness.engine.run_types import _EngineRun, _GraphState
|
|
41
|
+
from ksadk.harness.engine.skill_disclosure import SkillDisclosureBridge
|
|
42
|
+
from ksadk.harness.engine.steering import (
|
|
43
|
+
SteeringQueue,
|
|
44
|
+
SteerReceipt,
|
|
45
|
+
follow_up_origin,
|
|
46
|
+
follow_up_run,
|
|
47
|
+
steer_run,
|
|
48
|
+
)
|
|
49
|
+
from ksadk.harness.engine.thread_ids import encode_thread_id
|
|
50
|
+
from ksadk.harness.events import EventType, RuntimeEvent
|
|
51
|
+
from ksadk.harness.execution_policy import execution_policy_scope
|
|
52
|
+
from ksadk.harness.mcp_runtime import McpCapabilityRuntime
|
|
53
|
+
from ksadk.harness.multimodal import (
|
|
54
|
+
multimodal_user_content,
|
|
55
|
+
restore_multimodal_current_input,
|
|
56
|
+
runtime_input_text,
|
|
57
|
+
)
|
|
58
|
+
from ksadk.harness.prompt_cache import PromptCacheTracker
|
|
59
|
+
from ksadk.harness.reasoner import HarnessReasoner, ModelGatewayHarnessReasoner
|
|
60
|
+
from ksadk.harness.run_control import (
|
|
61
|
+
RunController,
|
|
62
|
+
RunControlStop,
|
|
63
|
+
run_control_spec_from_config,
|
|
64
|
+
)
|
|
65
|
+
from ksadk.harness.skill_runtime import SkillRuntime
|
|
66
|
+
from ksadk.harness.spec import HarnessSpec
|
|
67
|
+
from ksadk.harness.state import HarnessState, Message, MessageRole, RunStatus
|
|
68
|
+
from ksadk.harness.strategies import ExecutionStrategyRegistry
|
|
69
|
+
from ksadk.runtime import (
|
|
70
|
+
CancelResult,
|
|
71
|
+
PauseResult,
|
|
72
|
+
ResumePayload,
|
|
73
|
+
ResumeTarget,
|
|
74
|
+
RunHandle,
|
|
75
|
+
StartRequest,
|
|
76
|
+
)
|
|
77
|
+
|
|
78
|
+
_MAX_REASONING_TURNS = 8
|
|
79
|
+
|
|
80
|
+
|
|
81
|
+
class ManagedLangGraphEngine:
|
|
82
|
+
"""默认执行引擎:Revision 编译产物在 LangGraph 上运行。"""
|
|
83
|
+
|
|
84
|
+
def __init__(
|
|
85
|
+
self,
|
|
86
|
+
*,
|
|
87
|
+
reasoner: HarnessReasoner | None = None,
|
|
88
|
+
checkpointer: BaseCheckpointSaver | None = None,
|
|
89
|
+
tenant_id: str = "default",
|
|
90
|
+
tools: dict[str, Any] | None = None,
|
|
91
|
+
approval_required: set[str] | None = None,
|
|
92
|
+
context_engine: Any | None = None,
|
|
93
|
+
strategy_registry: ExecutionStrategyRegistry | None = None,
|
|
94
|
+
capability_runtime: Any | None = None,
|
|
95
|
+
sub_agents: dict[str, Any] | None = None,
|
|
96
|
+
memory_runtime: Any | None = None,
|
|
97
|
+
skill_runtime: SkillRuntime | None = None,
|
|
98
|
+
mcp_runtime: McpCapabilityRuntime | None = None,
|
|
99
|
+
context_contributors: tuple[Any, ...] = (),
|
|
100
|
+
hooks: tuple[Any, ...] = (),
|
|
101
|
+
artifact_store: Any | None = None,
|
|
102
|
+
mcp_offload_policy: Any | None = None,
|
|
103
|
+
delegation_runtime: Any | None = None,
|
|
104
|
+
event_sink: Callable[[str, str, RuntimeEvent], None] | None = None,
|
|
105
|
+
max_reasoning_turns: int = _MAX_REASONING_TURNS,
|
|
106
|
+
) -> None:
|
|
107
|
+
self._reasoner = reasoner or ModelGatewayHarnessReasoner()
|
|
108
|
+
self._checkpointer = checkpointer
|
|
109
|
+
# 集成项 4:Strategy Registry 真正参与 compile()——拓扑来自注册表。
|
|
110
|
+
self._strategy_registry = strategy_registry or ExecutionStrategyRegistry()
|
|
111
|
+
self._tenant_id = tenant_id
|
|
112
|
+
self._tools = tools or {}
|
|
113
|
+
# G10 §13.2:装配 ArtifactStore 时同步提供 artifact_read 取回工具
|
|
114
|
+
# (纳入 L0 工具面,审批分级走既有 tool_policy)。
|
|
115
|
+
if artifact_store is not None:
|
|
116
|
+
from ksadk.harness.tools import artifact_read_tool
|
|
117
|
+
|
|
118
|
+
self._tools.setdefault("artifact_read", artifact_read_tool(artifact_store))
|
|
119
|
+
self._approval_required = approval_required or set()
|
|
120
|
+
self._context_engine = context_engine
|
|
121
|
+
# G9 §12.3.1:ContextSection 贡献者在引擎构造期固化(不可变),
|
|
122
|
+
# Runtime 期只读;与 hooks 的 Compile 期固化纪律一致。
|
|
123
|
+
self._context_contributors = tuple(context_contributors)
|
|
124
|
+
# G5 §5.2:Provider 级扩展钩子(on_context 等),Compile 期固化。
|
|
125
|
+
self._hooks = tuple(hooks)
|
|
126
|
+
bind_hooked_reasoner(self) # G5 §5.2:hooks 非空时包装 Reasoner(provider 钩子)
|
|
127
|
+
# 收口 2:统一 CapabilityRuntime(Policy 决策 + Receipt 幂等)。
|
|
128
|
+
# 为 None 时 tool_calls 节点回退静态 approval_required 集合。
|
|
129
|
+
self._capability_runtime = capability_runtime
|
|
130
|
+
# 收口 6:子 Agent(名称 → SubAgentSpec);多 Agent 作为可选能力。
|
|
131
|
+
self._sub_agents = sub_agents or {}
|
|
132
|
+
if max_reasoning_turns < 1:
|
|
133
|
+
raise ValueError("max_reasoning_turns 必须为正整数")
|
|
134
|
+
self._max_reasoning_turns = max_reasoning_turns
|
|
135
|
+
# 长任务方案 §6.4:压缩前受控 Memory Flush 用的 Memory Runtime(可选)。
|
|
136
|
+
self._memory_runtime = memory_runtime
|
|
137
|
+
self._prompt_cache_tracker = PromptCacheTracker()
|
|
138
|
+
# SkillRuntime 只消费已绑定、已校验的 Skill 内容;L0 摘要常驻动态
|
|
139
|
+
# Context,L1/L2/L3 由默认 Agent Loop 的受限工具渐进披露。
|
|
140
|
+
self._skill_runtime = skill_runtime
|
|
141
|
+
self._skill_disclosure = SkillDisclosureBridge(skill_runtime)
|
|
142
|
+
# P0 MCP Deferred Tool Loading:McpCapabilityRuntime 复用健康缓存/
|
|
143
|
+
# 熔断/tools 缓存,披露层级(L0 目录/L1 列表/L2 Schema/L3 调用)
|
|
144
|
+
# 由 McpDisclosureBridge 接入默认 Loop。
|
|
145
|
+
self._mcp_runtime = mcp_runtime
|
|
146
|
+
# P1 大结果 Offload:L3 结果超阈值/命中敏感策略 → Artifact Store 外置。
|
|
147
|
+
# 策略对象同时供摘要输入脱敏复用(G12 §15.2 与 MCP Offload 同源正则)。
|
|
148
|
+
self._mcp_offload_policy = mcp_offload_policy
|
|
149
|
+
self._mcp_disclosure = McpDisclosureBridge(
|
|
150
|
+
mcp_runtime,
|
|
151
|
+
artifact_store=artifact_store,
|
|
152
|
+
offload_policy=mcp_offload_policy,
|
|
153
|
+
)
|
|
154
|
+
# Provider-owned dynamic delegation. The engine only knows the stable
|
|
155
|
+
# tool/runtime seam; provider selection remains outside the LangGraph
|
|
156
|
+
# execution kernel.
|
|
157
|
+
self._delegation_runtime = delegation_runtime
|
|
158
|
+
# P3 补强:事件出口回调(session_id, run_id, event)——洞察登记处
|
|
159
|
+
# (ksadk.harness.insights)由此拿到完整事件流,供 Studio API 消费。
|
|
160
|
+
self._event_sink = event_sink
|
|
161
|
+
# Context 构建管线(规划/压缩/组装/Manifest 投影,见 context_pipeline)。
|
|
162
|
+
self._context_pipeline = (
|
|
163
|
+
EngineContextPipeline(
|
|
164
|
+
context_engine=self._context_engine,
|
|
165
|
+
reasoner=self._reasoner,
|
|
166
|
+
event_fn=self._event,
|
|
167
|
+
memory_runtime=self._memory_runtime,
|
|
168
|
+
prompt_cache_tracker=self._prompt_cache_tracker,
|
|
169
|
+
context_contributors=self._context_contributors,
|
|
170
|
+
sensitive_policy=self._mcp_offload_policy,
|
|
171
|
+
hooks=self._hooks,
|
|
172
|
+
)
|
|
173
|
+
if self._context_engine is not None
|
|
174
|
+
else None
|
|
175
|
+
)
|
|
176
|
+
# 最近 compile 的 Spec(子 Agent 派生 child spec 用)。
|
|
177
|
+
self._current_spec: HarnessSpec | None = None
|
|
178
|
+
# 收口 6:子 Agent 事件缓冲(run_id → 待并入父流的子事件)。
|
|
179
|
+
# 子 Agent 在 tool_calls 节点内联执行,但事件必须等本节点自身的
|
|
180
|
+
# tool.call.begin/end 落定后统一重排并入,保证 seq 单调。
|
|
181
|
+
self._pending_child_events: dict[str, list[RuntimeEvent]] = {}
|
|
182
|
+
# 并行子 Agent 按 call_id 单独缓冲,节点结束时再按模型原始调用顺序
|
|
183
|
+
# 合并,避免墙钟完成顺序造成 Trace/重放结果不确定。
|
|
184
|
+
self._pending_subagent_events: dict[str, dict[str, list[RuntimeEvent]]] = {}
|
|
185
|
+
# parent_run_id -> call_id -> (child_engine, child_handle)。父取消必须先
|
|
186
|
+
# 显式传播到所有活动子 Run,不能只依赖 asyncio 任务树的隐式取消。
|
|
187
|
+
self._active_subagent_runs: dict[str, dict[str, tuple[Any, RunHandle]]] = {}
|
|
188
|
+
self._runs: dict[str, _EngineRun] = {}
|
|
189
|
+
# G1 流式中 Steering:引擎级队列,run 活跃性判断在方法内做。
|
|
190
|
+
self._steering = SteeringQueue()
|
|
191
|
+
|
|
192
|
+
# ------------------------------------------------------------- 只读视图
|
|
193
|
+
|
|
194
|
+
@property
|
|
195
|
+
def hooks(self) -> tuple[Any, ...]:
|
|
196
|
+
"""运行期只读的 Provider 钩子(构造期固化,G5)。"""
|
|
197
|
+
return self._hooks
|
|
198
|
+
|
|
199
|
+
# ------------------------------------------------------------- compile
|
|
200
|
+
|
|
201
|
+
async def compile(self, spec: HarnessSpec) -> CompiledHarness:
|
|
202
|
+
# 集成项 4:拓扑由 Strategy Registry 按 spec.execution_strategy 编译,
|
|
203
|
+
# 引擎不再硬编码 single_agent_plan。
|
|
204
|
+
plan = self._strategy_registry.compile(spec, strategy=spec.execution_strategy.kind.value)
|
|
205
|
+
if spec.execution_strategy.kind.value == self._strategy_registry.default():
|
|
206
|
+
ExecutionStrategyRegistry.assert_single_agent_purity(plan)
|
|
207
|
+
max_parallel = spec.execution_strategy.config.get("max_parallel_subagents", 4)
|
|
208
|
+
if isinstance(max_parallel, bool) or not isinstance(max_parallel, int):
|
|
209
|
+
raise ExecutionEngineError("max_parallel_subagents 必须是整数")
|
|
210
|
+
if not 1 <= max_parallel <= 32:
|
|
211
|
+
raise ExecutionEngineError("max_parallel_subagents 必须在 1..32 之间")
|
|
212
|
+
failure_mode = spec.execution_strategy.config.get("subagent_failure_mode", "partial")
|
|
213
|
+
if failure_mode not in {"partial", "fail_fast"}:
|
|
214
|
+
raise ExecutionEngineError("subagent_failure_mode 必须是 partial 或 fail_fast")
|
|
215
|
+
try:
|
|
216
|
+
run_control_spec_from_config(spec.execution_strategy.config)
|
|
217
|
+
except ValueError as exc:
|
|
218
|
+
raise ExecutionEngineError(f"run_control 配置无效: {exc}") from exc
|
|
219
|
+
declared_sub_agents = {binding.name for binding in spec.sub_agents}
|
|
220
|
+
self._skill_disclosure.validate_bindings(
|
|
221
|
+
spec,
|
|
222
|
+
tool_names=set(self._tools),
|
|
223
|
+
sub_agent_names=set(self._sub_agents) | declared_sub_agents,
|
|
224
|
+
)
|
|
225
|
+
self._mcp_disclosure.validate_bindings(
|
|
226
|
+
spec,
|
|
227
|
+
tool_names=set(self._tools),
|
|
228
|
+
sub_agent_names=set(self._sub_agents) | declared_sub_agents,
|
|
229
|
+
)
|
|
230
|
+
self._current_spec = spec
|
|
231
|
+
return CompiledHarness(
|
|
232
|
+
spec=spec,
|
|
233
|
+
plan=plan,
|
|
234
|
+
engine_kind="managed-langgraph",
|
|
235
|
+
)
|
|
236
|
+
|
|
237
|
+
# --------------------------------------------------------------- start
|
|
238
|
+
|
|
239
|
+
async def start(
|
|
240
|
+
self, request: StartRequest, compiled: CompiledHarness, *,
|
|
241
|
+
execution_policy=None, execution_policy_resolver=None, execution_policy_request=None,
|
|
242
|
+
) -> RunHandle:
|
|
243
|
+
run_id = str(request.metadata.get("invocation_id") or f"mle_{uuid.uuid4().hex[:16]}")
|
|
244
|
+
if run_id in self._runs:
|
|
245
|
+
raise ValueError(f"duplicate engine run: {run_id}")
|
|
246
|
+
state = HarnessState(
|
|
247
|
+
tenant_id=self._tenant_id,
|
|
248
|
+
user_id=request.user_id,
|
|
249
|
+
agent_id=str(request.agent_id or compiled.spec.agent_revision_ref),
|
|
250
|
+
session_id=request.session_id,
|
|
251
|
+
run_id=run_id,
|
|
252
|
+
status=RunStatus.PENDING,
|
|
253
|
+
)
|
|
254
|
+
checkpoint_session_id = str(
|
|
255
|
+
request.metadata.get("checkpoint_session_id") or request.session_id
|
|
256
|
+
)
|
|
257
|
+
thread_id = encode_thread_id(
|
|
258
|
+
tenant_id=self._tenant_id,
|
|
259
|
+
user_id=request.user_id,
|
|
260
|
+
agent_id=state.agent_id,
|
|
261
|
+
session_id=checkpoint_session_id,
|
|
262
|
+
run_id=run_id,
|
|
263
|
+
)
|
|
264
|
+
handle = RunHandle(
|
|
265
|
+
run_id=run_id,
|
|
266
|
+
session_id=request.session_id,
|
|
267
|
+
runtime_type="managed-langgraph",
|
|
268
|
+
native_ref={
|
|
269
|
+
"thread_id": thread_id,
|
|
270
|
+
"user_id": request.user_id,
|
|
271
|
+
"agent_id": state.agent_id,
|
|
272
|
+
**({"execution_policy_ref": request.metadata["execution_policy_ref"]}
|
|
273
|
+
if "execution_policy_ref" in request.metadata else {}),
|
|
274
|
+
**({"parent_run_id": request.metadata["parent_run_id"]}
|
|
275
|
+
if "parent_run_id" in request.metadata else {}),
|
|
276
|
+
},
|
|
277
|
+
)
|
|
278
|
+
from ksadk.harness.subagent import SubAgentSpec
|
|
279
|
+
|
|
280
|
+
revision_sub_agents = {
|
|
281
|
+
binding.name: SubAgentSpec.from_binding(binding)
|
|
282
|
+
for binding in compiled.spec.sub_agents
|
|
283
|
+
}
|
|
284
|
+
# Revision 是事实源;宿主同名配置只作为未编译旧路径的兼容兜底。
|
|
285
|
+
effective_sub_agents = {**self._sub_agents, **revision_sub_agents}
|
|
286
|
+
self._runs[run_id] = _EngineRun(
|
|
287
|
+
handle=handle,
|
|
288
|
+
request=request,
|
|
289
|
+
compiled=compiled,
|
|
290
|
+
state=state,
|
|
291
|
+
thread_id=thread_id,
|
|
292
|
+
skill_catalog=self._skill_disclosure.catalog(
|
|
293
|
+
compiled.spec, query=runtime_input_text(request.input)
|
|
294
|
+
),
|
|
295
|
+
mcp_catalog=self._mcp_disclosure.catalog(compiled.spec),
|
|
296
|
+
sub_agents=effective_sub_agents,
|
|
297
|
+
controller=self._new_run_controller(compiled),
|
|
298
|
+
)
|
|
299
|
+
configure_run(
|
|
300
|
+
self, self._runs[run_id], policy=execution_policy,
|
|
301
|
+
resolver=execution_policy_resolver, request=execution_policy_request,
|
|
302
|
+
)
|
|
303
|
+
return handle
|
|
304
|
+
|
|
305
|
+
# -------------------------------------------------------------- attach
|
|
306
|
+
|
|
307
|
+
def is_handle_attached(self, handle: RunHandle) -> bool:
|
|
308
|
+
"""Return whether this engine process already owns the live Run state."""
|
|
309
|
+
return handle.run_id in self._runs
|
|
310
|
+
|
|
311
|
+
async def attach(
|
|
312
|
+
self, handle: RunHandle, compiled: CompiledHarness, *, allow_completed: bool = False,
|
|
313
|
+
execution_policy=None, execution_policy_resolver=None, execution_policy_request=None,
|
|
314
|
+
) -> RunHandle:
|
|
315
|
+
"""跨进程恢复(收口 3):从持久 Checkpoint 重建 _EngineRun。
|
|
316
|
+
|
|
317
|
+
状态从 durable Checkpointer 的 graph snapshot 推断:存在未决 interrupt
|
|
318
|
+
→ awaiting_approval;存在 pending 节点 → paused;无 Checkpoint → 诚实报错。
|
|
319
|
+
事件队列从空开始(历史事件已由平台 EventStore 持久化)。
|
|
320
|
+
"""
|
|
321
|
+
if handle.run_id in self._runs:
|
|
322
|
+
return handle
|
|
323
|
+
if self._checkpointer is None:
|
|
324
|
+
raise ExecutionEngineError(
|
|
325
|
+
"attach 需要 durable Checkpointer:跨进程恢复依赖持久 Checkpoint"
|
|
326
|
+
)
|
|
327
|
+
thread_id = str(handle.native_ref.get("thread_id") or "")
|
|
328
|
+
if not thread_id:
|
|
329
|
+
raise ExecutionEngineError(
|
|
330
|
+
f"attach 失败:handle.native_ref 缺少 thread_id(run {handle.run_id!r})"
|
|
331
|
+
)
|
|
332
|
+
# 持久 handle 可能不带 user_id(旧版本句柄):用占位值,事件锚点以
|
|
333
|
+
# Checkpoint 内的图状态为准,跨进程身份由 thread_id 保证。
|
|
334
|
+
user_id = str(handle.native_ref.get("user_id") or "unknown")
|
|
335
|
+
agent_id = str(handle.native_ref.get("agent_id") or compiled.spec.agent_revision_ref)
|
|
336
|
+
state = HarnessState(
|
|
337
|
+
tenant_id=self._tenant_id,
|
|
338
|
+
user_id=user_id,
|
|
339
|
+
agent_id=agent_id,
|
|
340
|
+
session_id=handle.session_id,
|
|
341
|
+
run_id=handle.run_id,
|
|
342
|
+
status=RunStatus.PAUSED,
|
|
343
|
+
)
|
|
344
|
+
run = _EngineRun(
|
|
345
|
+
handle=handle,
|
|
346
|
+
request=StartRequest(
|
|
347
|
+
agent_id=agent_id,
|
|
348
|
+
user_id=user_id,
|
|
349
|
+
session_id=handle.session_id,
|
|
350
|
+
input="",
|
|
351
|
+
runtime_type="managed-langgraph",
|
|
352
|
+
metadata={
|
|
353
|
+
"invocation_id": handle.run_id,
|
|
354
|
+
**{key: handle.native_ref[key] for key in
|
|
355
|
+
("parent_run_id", "execution_policy_ref") if key in handle.native_ref},
|
|
356
|
+
},
|
|
357
|
+
),
|
|
358
|
+
compiled=compiled,
|
|
359
|
+
state=state,
|
|
360
|
+
thread_id=thread_id,
|
|
361
|
+
skill_catalog=self._skill_disclosure.catalog(compiled.spec),
|
|
362
|
+
mcp_catalog=self._mcp_disclosure.catalog(compiled.spec),
|
|
363
|
+
controller=self._new_run_controller(compiled),
|
|
364
|
+
)
|
|
365
|
+
run.started_emitted = True # run.started 已在首个进程发出
|
|
366
|
+
run.done = False
|
|
367
|
+
configure_run(
|
|
368
|
+
self, run, policy=execution_policy,
|
|
369
|
+
resolver=execution_policy_resolver, request=execution_policy_request,
|
|
370
|
+
)
|
|
371
|
+
# 从 Checkpoint snapshot 推断挂起状态。
|
|
372
|
+
graph = self._build_graph(run)
|
|
373
|
+
snapshot = await graph.aget_state({"configurable": {"thread_id": thread_id}})
|
|
374
|
+
if snapshot is None or not snapshot.values or (not snapshot.next and not allow_completed):
|
|
375
|
+
raise ExecutionEngineError(f"attach 失败:thread {thread_id!r} 无未决 Checkpoint")
|
|
376
|
+
tasks = getattr(snapshot, "tasks", None) or ()
|
|
377
|
+
if isinstance(tasks, dict):
|
|
378
|
+
tasks = tuple(tasks.values())
|
|
379
|
+
has_interrupt = any(getattr(task, "interrupts", None) for task in tasks)
|
|
380
|
+
for task in tasks:
|
|
381
|
+
for pending in getattr(task, "interrupts", ()):
|
|
382
|
+
value = getattr(pending, "value", {})
|
|
383
|
+
if isinstance(value, dict) and value.get("call_id"):
|
|
384
|
+
run.pending_approval_call_id = str(value["call_id"])
|
|
385
|
+
run.pending_approval = dict(value)
|
|
386
|
+
break
|
|
387
|
+
if run.controller is not None:
|
|
388
|
+
values = getattr(snapshot, "values", None) or {}
|
|
389
|
+
control_snapshot = values.get("run_control") if isinstance(values, dict) else None
|
|
390
|
+
if control_snapshot:
|
|
391
|
+
run.controller.restore(control_snapshot)
|
|
392
|
+
run.state.status = RunStatus.AWAITING_APPROVAL if has_interrupt else RunStatus.PAUSED
|
|
393
|
+
values = snapshot.values
|
|
394
|
+
budgets.restore(run, values.get("budget") or {})
|
|
395
|
+
run.seq = int(values.get("event_seq") or 0)
|
|
396
|
+
run.state.messages = self._messages(values.get("messages", []))
|
|
397
|
+
if not snapshot.next:
|
|
398
|
+
terminal = values.get("execution_terminal") or "completed"
|
|
399
|
+
run.state.status = RunStatus(terminal)
|
|
400
|
+
run.done = True
|
|
401
|
+
self._runs[handle.run_id] = run
|
|
402
|
+
from ksadk.harness.engine.subagents import restore_pending_child
|
|
403
|
+
|
|
404
|
+
await restore_pending_child(self, run)
|
|
405
|
+
return handle
|
|
406
|
+
|
|
407
|
+
# -------------------------------------------------------------- stream
|
|
408
|
+
|
|
409
|
+
def stream(self, handle: RunHandle) -> AsyncIterator[RuntimeEvent]:
|
|
410
|
+
return self._stream(handle)
|
|
411
|
+
|
|
412
|
+
async def _stream(self, handle: RunHandle) -> AsyncIterator[RuntimeEvent]:
|
|
413
|
+
run = self._require_run(handle)
|
|
414
|
+
task_finished = run.task is None or run.task.done()
|
|
415
|
+
if run.state.status in (RunStatus.AWAITING_APPROVAL, RunStatus.PAUSED) and task_finished:
|
|
416
|
+
# 挂起中:只回放未消费事件,不重启图(恢复必须走 resume)。
|
|
417
|
+
while run.events:
|
|
418
|
+
yield run.events.pop(0)
|
|
419
|
+
return
|
|
420
|
+
if run.done and task_finished:
|
|
421
|
+
while run.events:
|
|
422
|
+
yield run.events.pop(0)
|
|
423
|
+
return
|
|
424
|
+
if run.task is None or task_finished:
|
|
425
|
+
run.task = asyncio.create_task(self._execute(run))
|
|
426
|
+
try:
|
|
427
|
+
while True:
|
|
428
|
+
while run.events:
|
|
429
|
+
event = run.events.pop(0)
|
|
430
|
+
self._emit_insight(run, event)
|
|
431
|
+
yield event
|
|
432
|
+
if run.task.done():
|
|
433
|
+
break
|
|
434
|
+
await asyncio.sleep(0)
|
|
435
|
+
remaining = await run.task
|
|
436
|
+
for event in remaining:
|
|
437
|
+
self._emit_insight(run, event)
|
|
438
|
+
yield event
|
|
439
|
+
except asyncio.CancelledError:
|
|
440
|
+
# A subscriber timeout must cancel and await the executing graph,
|
|
441
|
+
# not just mark its output stream finished while tools keep running.
|
|
442
|
+
await self.cancel(handle)
|
|
443
|
+
raise
|
|
444
|
+
|
|
445
|
+
def _emit_insight(self, run: _EngineRun, event: RuntimeEvent) -> None:
|
|
446
|
+
"""事件出口统一回调(洞察登记处 / 审计侧消费;异常不阻断主流程)。"""
|
|
447
|
+
if self._event_sink is None:
|
|
448
|
+
return
|
|
449
|
+
try:
|
|
450
|
+
self._event_sink(run.state.session_id, run.handle.run_id, event)
|
|
451
|
+
except Exception: # noqa: BLE001 - 登记失败不阻断对话主流程
|
|
452
|
+
pass
|
|
453
|
+
|
|
454
|
+
def harness_capabilities(self):
|
|
455
|
+
"""返回运行时真实治理声明;该声明也随每个 Run 的首批事件保存。"""
|
|
456
|
+
from ksadk.harness.runtime_capabilities import managed_langgraph_capabilities
|
|
457
|
+
|
|
458
|
+
return managed_langgraph_capabilities()
|
|
459
|
+
|
|
460
|
+
async def _execute(
|
|
461
|
+
self,
|
|
462
|
+
run: _EngineRun,
|
|
463
|
+
resume_command: Command | None = None,
|
|
464
|
+
*,
|
|
465
|
+
resume_from_checkpoint: bool = False,
|
|
466
|
+
) -> list[RuntimeEvent]:
|
|
467
|
+
run.execution_started_at = time.monotonic()
|
|
468
|
+
spec = run.compiled.spec
|
|
469
|
+
run.state.status = RunStatus.RUNNING
|
|
470
|
+
if not run.started_emitted:
|
|
471
|
+
run.started_emitted = True
|
|
472
|
+
run.events.append(
|
|
473
|
+
self._event(
|
|
474
|
+
run, EventType.RUN_STARTED,
|
|
475
|
+
{"status": "in_progress", **follow_up_origin(run)},
|
|
476
|
+
)
|
|
477
|
+
)
|
|
478
|
+
# 收口 5:事件树根——Agent 生命周期(主 Agent 与未来子 Agent 同构)。
|
|
479
|
+
run.events.append(
|
|
480
|
+
self._event(run, EventType.AGENT_STARTED, {"agent_id": run.state.agent_id})
|
|
481
|
+
)
|
|
482
|
+
from ksadk.harness.engine.capability_declarations import (
|
|
483
|
+
capability_declarations,
|
|
484
|
+
)
|
|
485
|
+
|
|
486
|
+
run.events.extend(capability_declarations(self, run))
|
|
487
|
+
try:
|
|
488
|
+
if run.cancel_requested:
|
|
489
|
+
raise asyncio.CancelledError
|
|
490
|
+
await revalidate_policy(self, run)
|
|
491
|
+
graph = self._build_graph(run)
|
|
492
|
+
instructions = spec.prompt.instructions or ""
|
|
493
|
+
config = {
|
|
494
|
+
"configurable": {"thread_id": run.thread_id},
|
|
495
|
+
# Sequential tool checkpoints are graph steps too. The model
|
|
496
|
+
# turn/tool budgets, not LangGraph's default 25, govern a Run.
|
|
497
|
+
"recursion_limit": max(64, self._max_reasoning_turns * 128),
|
|
498
|
+
}
|
|
499
|
+
invoke_input: _GraphState | Command | None
|
|
500
|
+
if resume_command is not None:
|
|
501
|
+
invoke_input = resume_command
|
|
502
|
+
elif resume_from_checkpoint:
|
|
503
|
+
# 通用 pause 恢复:None → LangGraph 从最近 Checkpoint 续跑。
|
|
504
|
+
invoke_input = None
|
|
505
|
+
else:
|
|
506
|
+
# 收口 1:ContextEngine 真正控制首次模型输入(规划 + 主动/紧急压缩
|
|
507
|
+
# + 组装);未注入时回退旧的 history 拼接路径。
|
|
508
|
+
planned = await self._prepare_context(run, instructions)
|
|
509
|
+
if planned is not None:
|
|
510
|
+
conversation = planned
|
|
511
|
+
else:
|
|
512
|
+
history = run.request.metadata.get("conversation_history") or []
|
|
513
|
+
conversation = [{"role": "system", "content": instructions}]
|
|
514
|
+
skill_catalog_message = self._skill_disclosure.catalog_message(
|
|
515
|
+
run.skill_catalog
|
|
516
|
+
)
|
|
517
|
+
if skill_catalog_message:
|
|
518
|
+
conversation.append(skill_catalog_message)
|
|
519
|
+
mcp_catalog_message = self._mcp_disclosure.catalog_message(
|
|
520
|
+
run.mcp_catalog
|
|
521
|
+
)
|
|
522
|
+
if mcp_catalog_message:
|
|
523
|
+
conversation.append(mcp_catalog_message)
|
|
524
|
+
if isinstance(history, list) and history:
|
|
525
|
+
# 宿主(如 Studio Playground)注入的会话历史已含当前输入。
|
|
526
|
+
conversation.extend(dict(m) for m in history if isinstance(m, dict))
|
|
527
|
+
else:
|
|
528
|
+
conversation.append(
|
|
529
|
+
{
|
|
530
|
+
"role": "user",
|
|
531
|
+
"content": multimodal_user_content(run.request.input)
|
|
532
|
+
or runtime_input_text(run.request.input),
|
|
533
|
+
}
|
|
534
|
+
)
|
|
535
|
+
conversation = restore_multimodal_current_input(
|
|
536
|
+
conversation, run.request.input
|
|
537
|
+
)
|
|
538
|
+
invoke_input = {
|
|
539
|
+
"messages": conversation,
|
|
540
|
+
"pending_tool_calls": [],
|
|
541
|
+
"turn_count": 0,
|
|
542
|
+
"route": "reason",
|
|
543
|
+
"mcp_listed": [],
|
|
544
|
+
"mcp_schema_read": [],
|
|
545
|
+
"finalization_retries": 0,
|
|
546
|
+
"delegation_synthesis_pending": False,
|
|
547
|
+
"active_model_ref": run.compiled.spec.model.profile_ref,
|
|
548
|
+
"active_model_turns": 0,
|
|
549
|
+
"run_control": (
|
|
550
|
+
run.controller.snapshot() if run.controller is not None else {}
|
|
551
|
+
),
|
|
552
|
+
}
|
|
553
|
+
from ksadk.harness.engine.run_control_bridge import invoke_graph_with_control
|
|
554
|
+
|
|
555
|
+
with execution_policy_scope(run.execution_policy):
|
|
556
|
+
final_state = await invoke_graph_with_control(
|
|
557
|
+
graph, invoke_input, config, run.controller
|
|
558
|
+
)
|
|
559
|
+
interrupts = final_state.get("__interrupt__") if isinstance(final_state, dict) else None
|
|
560
|
+
if interrupts:
|
|
561
|
+
# Approval 挂起:图状态已由 Checkpointer 持久化,等待 resume。
|
|
562
|
+
run.state.status = RunStatus.AWAITING_APPROVAL
|
|
563
|
+
run.done = False
|
|
564
|
+
info = getattr(interrupts[0], "value", {}) or {}
|
|
565
|
+
run.pending_approval_call_id = str(info.get("call_id") or "")
|
|
566
|
+
run.pending_approval = dict(info)
|
|
567
|
+
approval_id = f"ap-{run.handle.run_id}-{info.get('call_id', '')}"
|
|
568
|
+
run.events.append(
|
|
569
|
+
self._event(
|
|
570
|
+
run,
|
|
571
|
+
EventType.APPROVAL_REQUESTED,
|
|
572
|
+
{
|
|
573
|
+
"approval_id": approval_id,
|
|
574
|
+
"call_id": str(info.get("call_id", "")),
|
|
575
|
+
"kind": "tool",
|
|
576
|
+
"tool_name": str(info.get("name") or ""),
|
|
577
|
+
"risk_level": str(info.get("risk") or ""),
|
|
578
|
+
"detail": info,
|
|
579
|
+
},
|
|
580
|
+
)
|
|
581
|
+
)
|
|
582
|
+
run.events.append(
|
|
583
|
+
self._event(
|
|
584
|
+
run,
|
|
585
|
+
EventType.RUN_INTERRUPTED,
|
|
586
|
+
{"status": "awaiting_approval", "reason": "tool_approval",
|
|
587
|
+
"approval_id": approval_id},
|
|
588
|
+
)
|
|
589
|
+
)
|
|
590
|
+
return []
|
|
591
|
+
# 影子状态消息(§6.2.1):完整对话消息投影,供 Transcript 持久化。
|
|
592
|
+
final_messages = final_state.get("messages", [])
|
|
593
|
+
run.state.messages = self._messages(final_messages)
|
|
594
|
+
# 最终答案事件由 reason 节点统一产生。这里仅投影 Transcript;若再从
|
|
595
|
+
# final_state 补发,stream 已消费 reason 事件时会造成同一答案重复展示。
|
|
596
|
+
if run.cancel_requested:
|
|
597
|
+
raise asyncio.CancelledError
|
|
598
|
+
from ksadk.harness.engine.completion_guard import unfinished_delegations
|
|
599
|
+
|
|
600
|
+
unfinished = unfinished_delegations(run.events)
|
|
601
|
+
if unfinished:
|
|
602
|
+
labels = ", ".join(unfinished.values())
|
|
603
|
+
raise ExecutionEngineError(
|
|
604
|
+
"parent run cannot complete while delegated children lack terminal "
|
|
605
|
+
f"evidence: {labels}"
|
|
606
|
+
)
|
|
607
|
+
run.state.status = RunStatus.COMPLETED
|
|
608
|
+
# 会话串轮修复(交接记录 2026-09-22 §7):把最终图状态的 turn_count
|
|
609
|
+
# 同步到 run.state,使 completion_payload 能据此派生 turn_id 写进
|
|
610
|
+
# RUN_COMPLETED payload,进而让 output_refs 指向当前轮的 turn 级
|
|
611
|
+
# final item_id(与 reason 节点写入 TEXT_COMPLETED 的 turn_id 对齐)。
|
|
612
|
+
run.state.turn_count = int(final_state.get("turn_count", 0) or 0)
|
|
613
|
+
# 最终组装窗口(最后一次 reason drain 之后到达的 steer)残留条目
|
|
614
|
+
# 升级进 follow_up 队列并补发升级回执,使其可被 adapter 续跑消费,
|
|
615
|
+
# 而不是滞留到 close()。
|
|
616
|
+
from ksadk.harness.engine.steering import upgrade_leftover_steering
|
|
617
|
+
|
|
618
|
+
upgrade_leftover_steering(self, run)
|
|
619
|
+
run.events.append(
|
|
620
|
+
self._event(
|
|
621
|
+
run,
|
|
622
|
+
EventType.AGENT_COMPLETED,
|
|
623
|
+
{"agent_id": run.state.agent_id, "status": "completed"},
|
|
624
|
+
)
|
|
625
|
+
)
|
|
626
|
+
from ksadk.harness.engine.run_control_bridge import completion_payload
|
|
627
|
+
|
|
628
|
+
payload = completion_payload(run)
|
|
629
|
+
run.events.append(self._event(run, EventType.RUN_COMPLETED, payload))
|
|
630
|
+
run.done = True
|
|
631
|
+
return []
|
|
632
|
+
except asyncio.CancelledError:
|
|
633
|
+
if run.pause_requested:
|
|
634
|
+
# 通用 pause:非终止性挂起,Checkpoint 持久化后可 resume。
|
|
635
|
+
run.pause_requested = False
|
|
636
|
+
run.state.status = RunStatus.PAUSED
|
|
637
|
+
run.done = False
|
|
638
|
+
run.events.append(
|
|
639
|
+
self._event(
|
|
640
|
+
run,
|
|
641
|
+
EventType.RUN_INTERRUPTED,
|
|
642
|
+
{"status": "paused", "reason": "pause_requested"},
|
|
643
|
+
)
|
|
644
|
+
)
|
|
645
|
+
return []
|
|
646
|
+
run.state.status = RunStatus.CANCELED
|
|
647
|
+
run.done = True
|
|
648
|
+
run.events.append(self._event(run, EventType.RUN_CANCELED, {"status": "cancelled"}))
|
|
649
|
+
self._steering.discard(run.handle.run_id)
|
|
650
|
+
return []
|
|
651
|
+
except GraphInterrupt as exc:
|
|
652
|
+
# checkpoint=False 路径(无 Checkpointer 时 interrupt 直接抛出)。
|
|
653
|
+
run.state.status = RunStatus.AWAITING_APPROVAL
|
|
654
|
+
run.done = False
|
|
655
|
+
run.events.append(
|
|
656
|
+
self._event(
|
|
657
|
+
run,
|
|
658
|
+
EventType.RUN_INTERRUPTED,
|
|
659
|
+
{"status": "awaiting_approval", "reason": f"graph_interrupt: {exc}"},
|
|
660
|
+
)
|
|
661
|
+
)
|
|
662
|
+
return []
|
|
663
|
+
except RunControlStop as exc:
|
|
664
|
+
from ksadk.harness.engine.run_control_bridge import append_controlled_stop
|
|
665
|
+
|
|
666
|
+
append_controlled_stop(self, run, exc.reason)
|
|
667
|
+
# 控制器硬停是终态:残留 steering/follow_up 不再有消费者。
|
|
668
|
+
self._steering.discard(run.handle.run_id)
|
|
669
|
+
return []
|
|
670
|
+
except Exception as exc: # noqa: BLE001
|
|
671
|
+
hooked_reasoner.flush_hook_degradations(self, run) # G5:失败终态前落残留降级
|
|
672
|
+
run.state.status = RunStatus.FAILED
|
|
673
|
+
run.done = True
|
|
674
|
+
run.events.append(
|
|
675
|
+
self._event(
|
|
676
|
+
run,
|
|
677
|
+
EventType.AGENT_COMPLETED,
|
|
678
|
+
{"agent_id": run.state.agent_id, "status": "failed"},
|
|
679
|
+
)
|
|
680
|
+
)
|
|
681
|
+
run.events.append(
|
|
682
|
+
self._event(
|
|
683
|
+
run,
|
|
684
|
+
EventType.RUN_FAILED,
|
|
685
|
+
{
|
|
686
|
+
"status": "failed",
|
|
687
|
+
"error": str(exc),
|
|
688
|
+
**(
|
|
689
|
+
{"error_category": str(exc.category)}
|
|
690
|
+
if getattr(exc, "category", None)
|
|
691
|
+
else {}
|
|
692
|
+
),
|
|
693
|
+
**(
|
|
694
|
+
{"error_category": str(exc.error_category)}
|
|
695
|
+
if getattr(exc, "error_category", None)
|
|
696
|
+
else {}
|
|
697
|
+
),
|
|
698
|
+
**(
|
|
699
|
+
{"error_code": str(exc.error_code)}
|
|
700
|
+
if getattr(exc, "error_code", None)
|
|
701
|
+
else {}
|
|
702
|
+
),
|
|
703
|
+
**(
|
|
704
|
+
{"status_code": int(exc.status_code)}
|
|
705
|
+
if getattr(exc, "status_code", None) is not None
|
|
706
|
+
else {}
|
|
707
|
+
),
|
|
708
|
+
},
|
|
709
|
+
)
|
|
710
|
+
)
|
|
711
|
+
# 失败同样是终态:adapter 不会在 RUN_FAILED 后续跑,残留条目应释放。
|
|
712
|
+
self._steering.discard(run.handle.run_id)
|
|
713
|
+
return []
|
|
714
|
+
|
|
715
|
+
finally:
|
|
716
|
+
budgets.account_elapsed(run)
|
|
717
|
+
run.execution_started_at = None
|
|
718
|
+
clear_hook_run(self, run)
|
|
719
|
+
|
|
720
|
+
# ---------------------------------------------------------------- graph
|
|
721
|
+
|
|
722
|
+
def _build_graph(self, run: _EngineRun):
|
|
723
|
+
# 图组装(节点实现/边/条件路由)拆至 graph_builder 模块,保持本模块
|
|
724
|
+
# <1000 行的仓库合同;节点闭包仍经 engine 访问运行时状态。
|
|
725
|
+
from ksadk.harness.engine.graph_builder import build_graph
|
|
726
|
+
|
|
727
|
+
return build_graph(self, run)
|
|
728
|
+
|
|
729
|
+
async def _invoke_tool(
|
|
730
|
+
self,
|
|
731
|
+
name: str,
|
|
732
|
+
arguments: dict[str, Any],
|
|
733
|
+
*,
|
|
734
|
+
run: Any = None,
|
|
735
|
+
mcp_cursors: McpDisclosureCursors | None = None,
|
|
736
|
+
call_id: str = "",
|
|
737
|
+
) -> Any:
|
|
738
|
+
from ksadk.harness.engine.tool_dispatch import invoke_tool
|
|
739
|
+
|
|
740
|
+
if run is not None:
|
|
741
|
+
await revalidate_policy(self, run)
|
|
742
|
+
with execution_policy_scope(run.execution_policy if run is not None else None):
|
|
743
|
+
return await invoke_tool(
|
|
744
|
+
self, name, arguments, run=run, mcp_cursors=mcp_cursors, call_id=call_id
|
|
745
|
+
)
|
|
746
|
+
|
|
747
|
+
# -------------------------------------------------------------- steering
|
|
748
|
+
|
|
749
|
+
def steer(
|
|
750
|
+
self, handle: RunHandle, text: str, *, allow_follow_up: bool = True
|
|
751
|
+
) -> SteerReceipt:
|
|
752
|
+
return steer_run(self, handle, text, allow_follow_up=allow_follow_up)
|
|
753
|
+
|
|
754
|
+
def follow_up(self, handle: RunHandle, text: str) -> SteerReceipt:
|
|
755
|
+
return follow_up_run(self, handle, text)
|
|
756
|
+
|
|
757
|
+
def pop_follow_up(self, run_id: str) -> str | None:
|
|
758
|
+
return self._steering.pop_follow_up(run_id)
|
|
759
|
+
|
|
760
|
+
# --------------------------------------------------------------- cancel
|
|
761
|
+
|
|
762
|
+
async def cancel(self, handle: RunHandle) -> CancelResult:
|
|
763
|
+
run = self._runs.get(handle.run_id)
|
|
764
|
+
if run is None or run.done:
|
|
765
|
+
return CancelResult.NOT_RUNNING
|
|
766
|
+
run.cancel_requested = True
|
|
767
|
+
active_children = list(self._active_subagent_runs.get(handle.run_id, {}).values())
|
|
768
|
+
active_task = run.task if run.task is not None and not run.task.done() else None
|
|
769
|
+
if active_task is not None:
|
|
770
|
+
active_task.cancel()
|
|
771
|
+
await asyncio.gather(active_task, return_exceptions=True)
|
|
772
|
+
else:
|
|
773
|
+
from ksadk.harness.engine.subagents import cancel_and_drain
|
|
774
|
+
from ksadk.harness.subagent import resequence_child_events
|
|
775
|
+
|
|
776
|
+
for child_engine, child_handle in active_children:
|
|
777
|
+
await cancel_and_drain(
|
|
778
|
+
child_engine, child_handle,
|
|
779
|
+
lambda event: resequence_child_events(run, [event], observe=True),
|
|
780
|
+
)
|
|
781
|
+
self._active_subagent_runs.pop(handle.run_id, None)
|
|
782
|
+
if self._delegation_runtime is not None:
|
|
783
|
+
await self._delegation_runtime.cancel_parent(handle.run_id)
|
|
784
|
+
if run.task is None and run.state.status is RunStatus.PENDING:
|
|
785
|
+
return CancelResult.PENDING_CANCEL_RECORDED
|
|
786
|
+
if active_task is None:
|
|
787
|
+
run.done = True
|
|
788
|
+
run.state.status = RunStatus.CANCELED
|
|
789
|
+
run.events.append(self._event(run, EventType.RUN_CANCELED, {"status": "cancelled"}))
|
|
790
|
+
self._steering.discard(handle.run_id)
|
|
791
|
+
return CancelResult.INTERRUPTED_ACTIVE_TURN
|
|
792
|
+
return CancelResult.INTERRUPTED_ACTIVE_TURN
|
|
793
|
+
|
|
794
|
+
# --------------------------------------------------------------- pause
|
|
795
|
+
|
|
796
|
+
async def pause(self, handle: RunHandle) -> PauseResult:
|
|
797
|
+
"""通用 pause:取消当前回合但保留状态,Checkpointer 持久化后可 resume。"""
|
|
798
|
+
run = self._runs.get(handle.run_id)
|
|
799
|
+
if run is None or run.done:
|
|
800
|
+
return PauseResult.NOT_RUNNING
|
|
801
|
+
if run.state.status not in (RunStatus.RUNNING, RunStatus.PENDING):
|
|
802
|
+
return PauseResult.NOT_RUNNING
|
|
803
|
+
if self._checkpointer is None:
|
|
804
|
+
return PauseResult.NOT_SUPPORTED
|
|
805
|
+
if run.task is None or run.task.done():
|
|
806
|
+
# 尚未启动流式执行:直接置 PAUSED,start 后由 stream/resume 驱动。
|
|
807
|
+
run.state.status = RunStatus.PAUSED
|
|
808
|
+
run.events.append(
|
|
809
|
+
self._event(
|
|
810
|
+
run,
|
|
811
|
+
EventType.RUN_INTERRUPTED,
|
|
812
|
+
{"status": "paused", "reason": "pause_requested"},
|
|
813
|
+
)
|
|
814
|
+
)
|
|
815
|
+
return PauseResult.PAUSED_ACTIVE_TURN
|
|
816
|
+
run.pause_requested = True
|
|
817
|
+
run.task.cancel()
|
|
818
|
+
return PauseResult.PAUSED_ACTIVE_TURN
|
|
819
|
+
|
|
820
|
+
# --------------------------------------------------------------- resume
|
|
821
|
+
|
|
822
|
+
async def resume(
|
|
823
|
+
self,
|
|
824
|
+
handle: RunHandle,
|
|
825
|
+
target: ResumeTarget,
|
|
826
|
+
payload: ResumePayload | None,
|
|
827
|
+
) -> RunHandle:
|
|
828
|
+
run = self._require_run(handle)
|
|
829
|
+
await revalidate_policy(self, run)
|
|
830
|
+
if run.state.status is RunStatus.PAUSED:
|
|
831
|
+
if self._checkpointer is None:
|
|
832
|
+
raise ExecutionEngineError(
|
|
833
|
+
"resume 需要 Checkpointer:pause 状态由 Checkpoint 持久化"
|
|
834
|
+
)
|
|
835
|
+
# 通用恢复:从最近 Checkpoint 续跑(非审批通道)。
|
|
836
|
+
run.state.status = RunStatus.RUNNING
|
|
837
|
+
run.events.append(
|
|
838
|
+
self._event(
|
|
839
|
+
run,
|
|
840
|
+
EventType.RUN_RESUMED,
|
|
841
|
+
{"target": target.id, "resume_kind": "checkpoint"},
|
|
842
|
+
)
|
|
843
|
+
)
|
|
844
|
+
run.task = asyncio.create_task(self._execute(run, resume_from_checkpoint=True))
|
|
845
|
+
return handle
|
|
846
|
+
if run.state.status is not RunStatus.AWAITING_APPROVAL:
|
|
847
|
+
raise ExecutionEngineError(
|
|
848
|
+
f"resume 仅支持 awaiting_approval 状态,当前 {run.state.status.value}"
|
|
849
|
+
)
|
|
850
|
+
if self._checkpointer is None:
|
|
851
|
+
raise ExecutionEngineError(
|
|
852
|
+
"resume 需要 Checkpointer:interrupt 状态由 Checkpoint 持久化"
|
|
853
|
+
)
|
|
854
|
+
if (
|
|
855
|
+
payload is None or payload.kind != "approval_decision"
|
|
856
|
+
or not run.pending_approval_call_id
|
|
857
|
+
or payload.call_id != run.pending_approval_call_id
|
|
858
|
+
or payload.data not in ("approved", "approved_session", "denied", "rejected")
|
|
859
|
+
):
|
|
860
|
+
raise ExecutionEngineError(
|
|
861
|
+
"approval resume requires an explicit decision for the pending call_id"
|
|
862
|
+
)
|
|
863
|
+
decision = "denied"
|
|
864
|
+
if payload is not None:
|
|
865
|
+
decision = str(payload.data) if payload.data is not None else "approved"
|
|
866
|
+
if decision == "approved_session":
|
|
867
|
+
run.session_approval_granted = True
|
|
868
|
+
run.approval_required = set()
|
|
869
|
+
run.events.append(
|
|
870
|
+
self._event(
|
|
871
|
+
run,
|
|
872
|
+
EventType.APPROVAL_RESOLVED,
|
|
873
|
+
{
|
|
874
|
+
"approval_id": f"ap-{run.handle.run_id}-{payload.call_id or ''}",
|
|
875
|
+
"call_id": payload.call_id or "",
|
|
876
|
+
"decision": decision,
|
|
877
|
+
"decided_by": (
|
|
878
|
+
"user_permanent"
|
|
879
|
+
if decision in {"approved", "approved_session"}
|
|
880
|
+
else "user_reject"
|
|
881
|
+
),
|
|
882
|
+
},
|
|
883
|
+
)
|
|
884
|
+
)
|
|
885
|
+
run.state.status = RunStatus.RUNNING
|
|
886
|
+
run.events.append(
|
|
887
|
+
self._event(
|
|
888
|
+
run,
|
|
889
|
+
EventType.RUN_RESUMED,
|
|
890
|
+
{"target": target.id, "resume_kind": "approval_decision"},
|
|
891
|
+
)
|
|
892
|
+
)
|
|
893
|
+
resume_decision = "approved" if decision == "approved_session" else decision
|
|
894
|
+
run.task = asyncio.create_task(
|
|
895
|
+
self._execute(run, resume_command=Command(resume=resume_decision))
|
|
896
|
+
)
|
|
897
|
+
return handle
|
|
898
|
+
|
|
899
|
+
# ------------------------------------------------------------- snapshot
|
|
900
|
+
|
|
901
|
+
async def snapshot_state(self, handle: RunHandle) -> HarnessState | None:
|
|
902
|
+
run = self._runs.get(handle.run_id)
|
|
903
|
+
return run.state if run else None
|
|
904
|
+
|
|
905
|
+
def capabilities(self) -> EngineCapabilityMatrix:
|
|
906
|
+
return EngineCapabilityMatrix(
|
|
907
|
+
cancel=EngineCapability(supported=True),
|
|
908
|
+
resume=EngineCapability(
|
|
909
|
+
supported=True, reason="approval + checkpoint (paused) channels"
|
|
910
|
+
),
|
|
911
|
+
checkpoint=EngineCapability(
|
|
912
|
+
supported=self._checkpointer is not None,
|
|
913
|
+
reason=None if self._checkpointer else "no checkpointer injected",
|
|
914
|
+
),
|
|
915
|
+
interrupt=EngineCapability(supported=True, reason="approval channel only"),
|
|
916
|
+
durable_across_process=EngineCapability(
|
|
917
|
+
supported=self._checkpointer is not None and _is_durable(self._checkpointer),
|
|
918
|
+
reason=None,
|
|
919
|
+
),
|
|
920
|
+
streaming=EngineCapability(supported=True),
|
|
921
|
+
)
|
|
922
|
+
|
|
923
|
+
async def close(self, handle: RunHandle) -> None:
|
|
924
|
+
if handle.run_id in self._runs and not self._runs[handle.run_id].done:
|
|
925
|
+
await self.cancel(handle)
|
|
926
|
+
run = self._runs.pop(handle.run_id, None)
|
|
927
|
+
if run and run.task and not run.task.done():
|
|
928
|
+
run.task.cancel()
|
|
929
|
+
await asyncio.gather(run.task, return_exceptions=True)
|
|
930
|
+
if run is not None:
|
|
931
|
+
self._skill_disclosure.clear_run(run.handle.run_id)
|
|
932
|
+
self._mcp_disclosure.clear_run(run.handle.run_id)
|
|
933
|
+
self._pending_child_events.pop(run.handle.run_id, None)
|
|
934
|
+
self._pending_subagent_events.pop(run.handle.run_id, None)
|
|
935
|
+
self._active_subagent_runs.pop(run.handle.run_id, None)
|
|
936
|
+
if self._delegation_runtime is not None:
|
|
937
|
+
self._delegation_runtime.clear_run(run.handle.run_id)
|
|
938
|
+
# close 是 Run 的终点:未消费的 steering 与未 pop 的 follow_up
|
|
939
|
+
# 必须释放,否则已关闭的 Run 仍会被续跑,且条目长期驻留内存。
|
|
940
|
+
self._steering.discard(run.handle.run_id)
|
|
941
|
+
|
|
942
|
+
# ------------------------------------------------------------- helpers
|
|
943
|
+
|
|
944
|
+
async def _prepare_context(
|
|
945
|
+
self, run: _EngineRun, instructions: str
|
|
946
|
+
) -> list[dict[str, Any]] | None:
|
|
947
|
+
"""Context 构建管线委托(长任务方案 §6/§8,实现见 context_pipeline)。"""
|
|
948
|
+
if self._context_engine is None:
|
|
949
|
+
return None
|
|
950
|
+
return await self._context_pipeline.prepare_context(run, instructions)
|
|
951
|
+
|
|
952
|
+
def _require_run(self, handle: RunHandle) -> _EngineRun:
|
|
953
|
+
try:
|
|
954
|
+
return self._runs[handle.run_id]
|
|
955
|
+
except KeyError:
|
|
956
|
+
raise KeyError(f"unknown engine run: {handle.run_id}") from None
|
|
957
|
+
|
|
958
|
+
async def _invoke_mcp_tool(
|
|
959
|
+
self,
|
|
960
|
+
name: str,
|
|
961
|
+
arguments: dict[str, Any],
|
|
962
|
+
*,
|
|
963
|
+
run: _EngineRun | None,
|
|
964
|
+
cursors: McpDisclosureCursors,
|
|
965
|
+
call_id: str = "",
|
|
966
|
+
) -> dict[str, Any]:
|
|
967
|
+
return await self._mcp_disclosure.invoke(
|
|
968
|
+
name,
|
|
969
|
+
arguments,
|
|
970
|
+
run=run,
|
|
971
|
+
cursors=cursors,
|
|
972
|
+
pending_events=self._pending_child_events,
|
|
973
|
+
call_id=call_id,
|
|
974
|
+
)
|
|
975
|
+
|
|
976
|
+
def _invoke_skill_tool(
|
|
977
|
+
self, name: str, arguments: dict[str, Any], *, run: _EngineRun | None
|
|
978
|
+
) -> dict[str, Any]:
|
|
979
|
+
return self._skill_disclosure.invoke(
|
|
980
|
+
name,
|
|
981
|
+
arguments,
|
|
982
|
+
run=run,
|
|
983
|
+
pending_events=self._pending_child_events,
|
|
984
|
+
)
|
|
985
|
+
|
|
986
|
+
def _event(
|
|
987
|
+
self, run: _EngineRun, event_type: str, payload: dict[str, Any], *, phase: str | None = None
|
|
988
|
+
) -> RuntimeEvent:
|
|
989
|
+
run.seq += 1
|
|
990
|
+
event = RuntimeEvent.create(
|
|
991
|
+
event_type,
|
|
992
|
+
agent_id=run.state.agent_id,
|
|
993
|
+
user_id=run.state.user_id,
|
|
994
|
+
session_id=run.state.session_id,
|
|
995
|
+
invocation_id=run.handle.run_id,
|
|
996
|
+
seq_id=run.seq,
|
|
997
|
+
payload=payload,
|
|
998
|
+
phase=phase,
|
|
999
|
+
)
|
|
1000
|
+
if run.controller is not None:
|
|
1001
|
+
run.control_events.append(event)
|
|
1002
|
+
run.controller.observe(event)
|
|
1003
|
+
run.observed_event_ids.add(event.event_id)
|
|
1004
|
+
return event
|
|
1005
|
+
|
|
1006
|
+
@staticmethod
|
|
1007
|
+
def _messages(messages):
|
|
1008
|
+
return [
|
|
1009
|
+
Message(
|
|
1010
|
+
role=MessageRole(m.get("role", "user")), content=str(m.get("content") or ""),
|
|
1011
|
+
tool_call_id=str(m["tool_call_id"]) if m.get("tool_call_id") else None,
|
|
1012
|
+
name=str(m["name"]) if m.get("name") else None,
|
|
1013
|
+
)
|
|
1014
|
+
for m in messages if isinstance(m, dict)
|
|
1015
|
+
]
|
|
1016
|
+
|
|
1017
|
+
@staticmethod
|
|
1018
|
+
def _new_run_controller(compiled: CompiledHarness) -> RunController | None:
|
|
1019
|
+
from ksadk.harness.engine.run_control_bridge import new_run_controller
|
|
1020
|
+
|
|
1021
|
+
return new_run_controller(compiled)
|
|
1022
|
+
|
|
1023
|
+
|
|
1024
|
+
def _is_durable(checkpointer: BaseCheckpointSaver) -> bool:
|
|
1025
|
+
"""SQLite/Postgres Checkpointer 视为跨进程持久;MemorySaver 不是。"""
|
|
1026
|
+
from langgraph.checkpoint.memory import InMemorySaver, MemorySaver
|
|
1027
|
+
|
|
1028
|
+
return not isinstance(checkpointer, (MemorySaver, InMemorySaver))
|
|
1029
|
+
|
|
1030
|
+
|
|
1031
|
+
def memory_checkpointer() -> BaseCheckpointSaver:
|
|
1032
|
+
"""进程内 Checkpointer(langgraph 类型不越出本模块的架构合同)。"""
|
|
1033
|
+
from langgraph.checkpoint.memory import InMemorySaver
|
|
1034
|
+
|
|
1035
|
+
return InMemorySaver()
|
|
1036
|
+
|
|
1037
|
+
|
|
1038
|
+
def sqlite_checkpointer(db_path: str) -> Any:
|
|
1039
|
+
"""SQLite 异步 Checkpointer 的上下文管理器(调用方负责 __aenter__)。
|
|
1040
|
+
|
|
1041
|
+
经由本工厂获取,避免 langgraph import 越出引擎模块
|
|
1042
|
+
(tests/architecture/test_harness_contract.py 守卫)。
|
|
1043
|
+
"""
|
|
1044
|
+
from langgraph.checkpoint.sqlite.aio import AsyncSqliteSaver
|
|
1045
|
+
|
|
1046
|
+
return AsyncSqliteSaver.from_conn_string(db_path)
|
|
1047
|
+
|
|
1048
|
+
|
|
1049
|
+
__all__ = ["ManagedLangGraphEngine", "memory_checkpointer", "sqlite_checkpointer"]
|