agentengine-sdk-python 0.8.6__py3-none-any.whl → 0.8.8__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.6.dist-info → agentengine_sdk_python-0.8.8.dist-info}/METADATA +41 -18
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.8.dist-info}/RECORD +710 -526
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.8.dist-info}/WHEEL +1 -1
- ksadk/__init__.py +2 -1
- ksadk/_build_provenance.json +1 -1
- ksadk/_mcp_compat.py +305 -0
- ksadk/a2a/_invocation_state.py +1 -1
- ksadk/a2a/adk_invocation_context.py +2 -1
- ksadk/a2a/adk_tools.py +19 -9
- ksadk/a2a/bootstrap.py +7 -6
- ksadk/a2a/codex.py +2 -1
- ksadk/a2a/control_plane.py +119 -2
- ksadk/a2a/executor.py +24 -7
- ksadk/a2a/invocation_service.py +198 -7
- ksadk/a2a/kernel_task_adapter.py +60 -9
- ksadk/a2a/langgraph_invocation_context.py +3 -2
- ksadk/a2a/langgraph_managed.py +17 -1
- ksadk/a2a/langgraph_recovery.py +43 -5
- ksadk/a2a/langgraph_tool_runtime.py +8 -6
- ksadk/a2a/langgraph_tools.py +13 -1
- ksadk/a2a/platform.py +8 -2
- ksadk/a2a/runtime_approval.py +6 -21
- ksadk/a2a/runtime_input.py +3 -2
- ksadk/a2a/timeouts.py +37 -0
- ksadk/a2a/tool_outcomes.py +73 -0
- ksadk/a2a/workload_tokens.py +21 -134
- ksadk/a2ui/__init__.py +4 -0
- ksadk/a2ui/assets/basic-v0_9_1.json +1383 -0
- ksadk/a2ui/assets/common-types-v0_9.json +305 -0
- ksadk/a2ui/assets/legacy-seven-components.json +230 -0
- ksadk/a2ui/assets/manifest.json +86 -0
- ksadk/a2ui/budget.py +54 -0
- ksadk/a2ui/catalog.py +64 -0
- ksadk/a2ui/generation.py +71 -0
- ksadk/a2ui/legacy.py +88 -0
- ksadk/a2ui/linking.py +115 -0
- ksadk/a2ui/payload.py +46 -0
- ksadk/a2ui/presentation.py +79 -0
- ksadk/a2ui/registry.py +166 -0
- ksadk/a2ui/wire.py +110 -0
- ksadk/agent.py +29 -0
- ksadk/agui/_agent_helpers.py +16 -1
- ksadk/agui/_agent_kernel.py +515 -0
- ksadk/agui/_agent_projection.py +379 -0
- ksadk/agui/_agent_resume.py +279 -0
- ksadk/agui/_agent_types.py +67 -0
- ksadk/agui/a2ui_projection.py +3 -1
- ksadk/agui/agent.py +184 -571
- ksadk/agui/config.py +19 -5
- ksadk/agui/hosted.py +343 -0
- ksadk/agui/request_identity.py +11 -0
- ksadk/agui/routes.py +79 -2
- ksadk/api/client.py +158 -7
- ksadk/builders/code_builder.py +174 -52
- ksadk/builders/container_builder.py +28 -7
- ksadk/builders/framework_requirements.py +5 -4
- ksadk/builders/mcp_builder.py +145 -1
- ksadk/builders/project_imports.py +66 -0
- ksadk/cli/cmd_deploy.py +5 -0
- ksadk/cli/cmd_invoke.py +57 -2
- ksadk/cli/cmd_mcp.py +1 -1
- ksadk/cli/cmd_run.py +2 -4
- ksadk/cli/cmd_studio.py +19 -3
- ksadk/cli/cmd_web.py +28 -56
- ksadk/cli/hosted_command_events.py +148 -0
- ksadk/cli/hosted_invoke.py +66 -14
- ksadk/cli/runtime_bootstrap.py +5 -1
- ksadk/codex/async_client.py +354 -12
- ksadk/codex/runtime.py +17 -2
- ksadk/common/cloud_headers.py +33 -6
- ksadk/common/diagnostics.py +15 -0
- ksadk/compat/adk_compat.py +2 -0
- ksadk/compat/adk_stream.py +35 -0
- ksadk/compat/copilotkit_a2ui.py +85 -21
- ksadk/configs/env_registry.py +102 -19
- ksadk/configs/env_registry_a2a.py +42 -0
- ksadk/conversations/a2ui_projection.py +50 -0
- ksadk/conversations/context.py +12 -0
- ksadk/conversations/message_projection.py +106 -60
- ksadk/conversations/message_projection_blocks.py +75 -3
- ksadk/conversations/message_projection_outcomes.py +81 -0
- ksadk/conversations/projector.py +35 -0
- ksadk/conversations/runtime_invocation.py +3 -0
- ksadk/conversations/runtime_observability.py +1 -0
- ksadk/conversations/runtime_projection.py +23 -1
- ksadk/conversations/runtime_stream_events.py +11 -7
- ksadk/conversations/runtime_streaming.py +21 -17
- ksadk/deployment/mcp.py +93 -0
- ksadk/deployment/providers/serverless.py +130 -4
- ksadk/detection/mcp_detector.py +80 -22
- ksadk/events/_v1_compat/projection.py +2 -0
- ksadk/events/adapters/_langgraph_custom.py +195 -0
- ksadk/events/adapters/_langgraph_model_tasks.py +59 -0
- ksadk/events/adapters/_langgraph_support.py +80 -29
- ksadk/events/adapters/_langgraph_tool_outcomes.py +71 -0
- ksadk/events/adapters/_langgraph_usage_origin.py +86 -0
- ksadk/events/adapters/adk.py +11 -0
- ksadk/events/adapters/langgraph.py +188 -20
- ksadk/events/canonical.py +23 -1
- ksadk/events/canonical_store.py +133 -4
- ksadk/events/cold_recovery.py +2 -1
- ksadk/events/native_checkpoint.py +10 -0
- ksadk/events/reducer.py +9 -9
- ksadk/events/run_authority.py +15 -0
- ksadk/events/session_event.py +61 -0
- ksadk/events/sse_heartbeat.py +50 -0
- ksadk/events/usage.py +50 -0
- ksadk/harness/__init__.py +3 -0
- ksadk/harness/app.py +1 -1
- ksadk/harness/artifact_adapters/native_catalog.py +92 -0
- ksadk/harness/artifact_adapters/native_tool.py +16 -0
- ksadk/harness/browser_adapters/native_playwright.py +3 -1
- ksadk/harness/browser_adapters/native_vision.py +2 -1
- ksadk/harness/engine/postgres_checkpointer.py +170 -29
- ksadk/harness/model_adapters/native_openai.py +3 -1
- ksadk/harness/native/artifact_catalog_contract.py +26 -0
- ksadk/harness/native/artifact_partial_read_capacity.py +6 -3
- ksadk/harness/native/artifact_read_capacity.py +15 -87
- ksadk/harness/native/artifact_runtime.py +44 -1
- ksadk/harness/native/artifact_search_capacity.py +20 -119
- ksadk/harness/native/artifact_single_read_capacity.py +7 -6
- ksadk/harness/native/background_command_contract.py +40 -0
- ksadk/harness/native/background_commands.py +101 -0
- ksadk/harness/native/call_budget.py +24 -0
- ksadk/harness/native/child_budget.py +6 -6
- ksadk/harness/native/child_interruption.py +3 -2
- ksadk/harness/native/child_media.py +105 -0
- ksadk/harness/native/context.py +44 -0
- ksadk/harness/native/context_compaction_projection.py +38 -2
- ksadk/harness/native/context_continuation.py +54 -0
- ksadk/harness/native/context_contributions.py +2 -1
- ksadk/harness/native/context_directory_progress.py +117 -0
- ksadk/harness/native/context_driver.py +136 -11
- ksadk/harness/native/context_partial_summary.py +2 -0
- ksadk/harness/native/context_partition.py +37 -1
- ksadk/harness/native/context_replay.py +2 -1
- ksadk/harness/native/context_request_projection.py +59 -6
- ksadk/harness/native/context_runtime.py +211 -16
- ksadk/harness/native/context_runtime_contracts.py +123 -1
- ksadk/harness/native/context_session_history.py +96 -0
- ksadk/harness/native/context_source_progress.py +164 -5
- ksadk/harness/native/context_summary_planning.py +63 -15
- ksadk/harness/native/context_summary_prompt.py +72 -0
- ksadk/harness/native/context_summary_recovery.py +3 -1
- ksadk/harness/native/delivery_artifacts.py +58 -0
- ksadk/harness/native/delivery_context.py +64 -0
- ksadk/harness/native/delivery_feedback.py +95 -0
- ksadk/harness/native/delivery_review.py +10 -10
- ksadk/harness/native/effect_control.py +45 -1
- ksadk/harness/native/effect_receipts.py +50 -3
- ksadk/harness/native/effect_runtime.py +10 -1
- ksadk/harness/native/engine.py +601 -16
- ksadk/harness/native/execution_budget.py +88 -0
- ksadk/harness/native/history.py +1 -0
- ksadk/harness/native/machine.py +44 -7
- ksadk/harness/native/model.py +17 -3
- ksadk/harness/native/model_runtime.py +192 -12
- ksadk/harness/native/model_takeover.py +4 -2
- ksadk/harness/native/notification_admission.py +183 -0
- ksadk/harness/native/ports.py +54 -6
- ksadk/harness/native/run_clock.py +13 -6
- ksadk/harness/native/state.py +100 -1
- ksadk/harness/native/stream_display_buffer.py +198 -0
- ksadk/harness/native/subagents.py +21 -0
- ksadk/harness/native/task_policy.py +8 -3
- ksadk/harness/native/tool_batch_capacity.py +152 -0
- ksadk/harness/native/tool_budget.py +38 -9
- ksadk/harness/native/tool_error_recovery.py +241 -0
- ksadk/harness/native/tool_error_streak.py +10 -1
- ksadk/harness/native/tool_progress.py +1 -0
- ksadk/harness/native/tool_scheduling.py +9 -10
- ksadk/harness/native/turn_control.py +21 -2
- ksadk/harness/native/verification_runtime.py +2 -1
- ksadk/harness/native_facade.py +180 -9
- ksadk/harness/native_projection.py +18 -8
- ksadk/harness/native_runtime.py +208 -3
- ksadk/harness/provider_thinking.py +63 -0
- ksadk/harness/public_activity.py +3 -0
- ksadk/harness/service_presentation.py +44 -0
- ksadk/harness/service_runtime.py +1038 -0
- ksadk/harness/skill_adapters/native_disclosure.py +13 -1
- ksadk/harness/skill_adapters/native_metadata.py +40 -0
- ksadk/harness/spec.py +6 -0
- ksadk/harness/stores/native_commit_history.py +373 -0
- ksadk/harness/stores/native_contract.py +205 -1
- ksadk/harness/stores/native_memory.py +363 -1
- ksadk/harness/stores/native_sqlite.py +572 -14
- ksadk/harness/stores/native_sqlite_migration.py +34 -7
- ksadk/harness/subagent.py +6 -1
- ksadk/harness/subagent_adapters/native_background_child.py +8 -7
- ksadk/harness/subagent_adapters/native_child.py +87 -8
- ksadk/harness/tool_display.py +113 -2
- ksadk/harness/tool_display_contract.py +34 -1
- ksadk/interaction/contracts.py +19 -4
- ksadk/interaction/display_values.py +140 -0
- ksadk/interaction/form_values.py +130 -0
- ksadk/interaction/langgraph.py +53 -0
- ksadk/interaction/langgraph_approval.py +59 -0
- ksadk/interaction/langgraph_interrupt.py +129 -0
- ksadk/interaction/langgraph_observer.py +125 -0
- ksadk/interaction/ledger.py +32 -5
- ksadk/interaction/native_events.py +29 -0
- ksadk/interaction/providers/harness.py +9 -4
- ksadk/interaction/providers/langgraph.py +19 -8
- ksadk/interaction/resolution.py +43 -0
- ksadk/interaction/schema.py +168 -0
- ksadk/interaction/submission.py +184 -0
- ksadk/kernel/admission_cursor.py +19 -0
- ksadk/kernel/bootstrap.py +344 -228
- ksadk/kernel/contract_fingerprints.py +5 -0
- ksadk/kernel/contracts.py +1 -0
- ksadk/kernel/control.py +67 -0
- ksadk/kernel/conversation_input.py +39 -0
- ksadk/kernel/execution_host_ingress.py +6 -3
- ksadk/kernel/history_projection.py +85 -4
- ksadk/kernel/ingress.py +89 -27
- ksadk/kernel/interactions_memory.py +447 -0
- ksadk/kernel/interactions_postgres.py +500 -0
- ksadk/kernel/interactions_sqlite.py +684 -0
- ksadk/kernel/legacy_postgres_repair.py +113 -0
- ksadk/kernel/local_interactions.py +172 -0
- ksadk/kernel/memory_store.py +137 -366
- ksadk/kernel/native_confirmation.py +109 -0
- ksadk/kernel/postgres_locks.py +23 -0
- ksadk/kernel/postgres_store.py +573 -511
- ksadk/kernel/postgres_time.py +12 -0
- ksadk/kernel/recovery.py +26 -1
- ksadk/kernel/runtime_config.py +72 -0
- ksadk/kernel/runtime_environment.py +301 -0
- ksadk/kernel/session_storage.py +144 -0
- ksadk/kernel/sql/002_session_retirement.sql +86 -0
- ksadk/kernel/sql/003_legacy_repair_queue.sql +49 -0
- ksadk/kernel/sql/backfill_session_namespaces.sql +59 -0
- ksadk/kernel/sqlite_session_cleanup.py +84 -0
- ksadk/kernel/sqlite_store.py +232 -622
- ksadk/kernel/store.py +6 -0
- ksadk/kernel/submission_postgres.py +99 -0
- ksadk/kernel/submission_sqlite.py +107 -0
- ksadk/kernel/teams_effects.py +3 -4
- ksadk/kernel/teams_execution_context.py +3 -4
- ksadk/kernel/worker.py +91 -202
- ksadk/kernel/worker_controls.py +112 -27
- ksadk/kernel/worker_identity.py +15 -8
- ksadk/kernel/worker_interactions.py +343 -47
- ksadk/knowledge_base/__init__.py +1 -1
- ksadk/knowledge_base/client.py +138 -17
- ksadk/knowledge_base/openclaw_bridge.py +58 -0
- ksadk/knowledge_base/service.py +2 -0
- ksadk/mcp_runtime/__init__.py +34 -15
- ksadk/mcp_runtime/_adk.py +14 -0
- ksadk/mcp_runtime/oauth/__init__.py +6 -0
- ksadk/mcp_runtime/oauth/_agent.py +215 -0
- ksadk/mcp_runtime/oauth/_durable_tools.py +208 -0
- ksadk/mcp_runtime/oauth/bootstrap.py +69 -0
- ksadk/mcp_runtime/oauth/client.py +200 -0
- ksadk/mcp_runtime/oauth/code_config.py +90 -0
- ksadk/mcp_runtime/oauth/contract.json +32 -0
- ksadk/mcp_runtime/oauth/contract.py +6 -0
- ksadk/mcp_runtime/oauth/declarations.py +106 -0
- ksadk/mcp_runtime/oauth/http.py +63 -0
- ksadk/mcp_runtime/oauth/kernel.py +717 -0
- ksadk/mcp_runtime/oauth/langgraph.py +434 -0
- ksadk/mcp_runtime/oauth/local/__init__.py +1 -0
- ksadk/mcp_runtime/oauth/local/broker.py +491 -0
- ksadk/mcp_runtime/oauth/local/checkpoint.py +17 -0
- ksadk/mcp_runtime/oauth/local/persistence.py +227 -0
- ksadk/mcp_runtime/oauth/local/protocol.py +390 -0
- ksadk/mcp_runtime/oauth/local/runtime.py +413 -0
- ksadk/mcp_runtime/oauth/local/transport.py +79 -0
- ksadk/mcp_runtime/oauth/runtime_io.py +43 -0
- ksadk/mcp_runtime/oauth/security.py +73 -0
- ksadk/mcp_runtime/oauth/tools.py +434 -0
- ksadk/mcp_runtime/oauth/transport.py +109 -0
- ksadk/memory/adk/backends/sdk_ltm_backend.py +21 -12
- ksadk/memory/adk/long_term_memory.py +1 -2
- ksadk/memory/openclaw_bridge.py +115 -0
- ksadk/memory/providers/local_postgres.py +247 -55
- ksadk/memory/scope_ids.py +49 -0
- ksadk/memory/service.py +29 -3
- ksadk/model_gateway/client.py +1 -1
- ksadk/model_proxy/compat.py +22 -0
- ksadk/model_proxy/transform.py +3 -4
- ksadk/plugins/providers/codex.py +37 -2
- ksadk/plugins/providers/harness.py +65 -28
- ksadk/plugins/providers/harness_service.py +198 -0
- ksadk/plugins/providers/harness_service_context.py +175 -0
- ksadk/plugins/providers/harness_service_hooks.py +168 -0
- ksadk/plugins/providers/harness_service_memory.py +479 -0
- ksadk/plugins/providers/harness_tools.py +39 -2
- ksadk/plugins/providers/platform_resources.py +2 -2
- ksadk/resource_runtime/contracts.py +8 -3
- ksadk/resource_runtime/knowledge.py +1 -1
- ksadk/resource_runtime/langgraph.py +7 -3
- ksadk/resource_runtime/managed_projection.py +24 -9
- ksadk/resource_runtime/mcp_server.py +3 -3
- ksadk/resource_runtime/worker.py +24 -5
- ksadk/runners/_adk_a2a_stream.py +10 -0
- ksadk/runners/_adk_canonical_stream.py +38 -10
- ksadk/runners/_adk_tunnel_history.py +96 -0
- ksadk/runners/_langgraph_answer_contract.py +47 -0
- ksadk/runners/_langgraph_canonical_stream.py +657 -0
- ksadk/runners/_langgraph_checkpoint_binding.py +89 -0
- ksadk/runners/_langgraph_factory.py +79 -0
- ksadk/runners/_langgraph_final_answer.py +91 -0
- ksadk/runners/_langgraph_fresh_turn.py +67 -0
- ksadk/runners/_langgraph_interactions.py +199 -0
- ksadk/runners/_langgraph_output.py +69 -0
- ksadk/runners/_langgraph_runner_streams.py +38 -75
- ksadk/runners/_langgraph_state_reader.py +5 -0
- ksadk/runners/_langgraph_wait_cancellation.py +49 -0
- ksadk/runners/_session_identity.py +30 -4
- ksadk/runners/adk_runner.py +108 -22
- ksadk/runners/base_runner.py +21 -0
- ksadk/runners/langgraph_runner.py +122 -108
- ksadk/runners/patch_langchain.py +4 -2
- ksadk/runtime/_langgraph_interaction_adapter.py +333 -0
- ksadk/runtime/_runner_adapter/a2ui_surface.py +194 -22
- ksadk/runtime/_runner_adapter/chunk_mapping.py +688 -0
- ksadk/runtime/_runner_adapter/resume_context.py +64 -0
- ksadk/runtime/_runner_adapter/stream_mapping.py +29 -597
- ksadk/runtime/conversation_execution.py +61 -32
- ksadk/runtime/executor.py +34 -1
- ksadk/runtime/factory.py +17 -5
- ksadk/runtime/framework_adapters.py +37 -2
- ksadk/runtime/langgraph_checkpoint_view.py +168 -0
- ksadk/runtime/launch.py +2 -0
- ksadk/runtime/preprocessing.py +9 -1
- ksadk/runtime/runner_adapter.py +77 -37
- ksadk/runtime/session_storage.py +71 -0
- ksadk/sandbox/backends/e2b.py +95 -13
- ksadk/sandbox/backends/local_process.py +68 -4
- ksadk/sandbox/base.py +1 -1
- ksadk/sandbox/diagnostics.py +31 -0
- ksadk/sandbox/e2b_background.py +1768 -0
- ksadk/sandbox/e2b_errors.py +26 -0
- ksadk/sandbox/local_background.py +406 -0
- ksadk/sandbox/local_controls.py +8 -1
- ksadk/server/database_access.py +369 -0
- ksadk/server/database_access_contract.py +222 -0
- ksadk/server/factory.py +180 -3
- ksadk/server/history_deadline.py +20 -4
- ksadk/server/history_page_cache.py +8 -2
- ksadk/server/routes/common.py +13 -1
- ksadk/server/routes/control.py +2 -1
- ksadk/server/routes/database_access.py +17 -0
- ksadk/server/routes/dependencies.py +28 -0
- ksadk/server/routes/harness_service_view.py +38 -0
- ksadk/server/routes/interactions.py +106 -0
- ksadk/server/routes/kernel_ingress.py +19 -1
- ksadk/server/routes/local_kernel_control.py +80 -0
- ksadk/server/routes/openai_compat.py +6 -0
- ksadk/server/routes/projection.py +159 -2
- ksadk/server/routes/routers.py +6 -0
- ksadk/server/routes/run.py +30 -1
- ksadk/server/routes/session_identity.py +130 -0
- ksadk/server/routes/sessions.py +326 -312
- ksadk/server/routes/streaming.py +3 -2
- ksadk/server/routes/ui_bootstrap.py +265 -0
- ksadk/server/routes/workspace.py +7 -0
- ksadk/server/static/a2ui/basic-v0_9_1.json +1383 -0
- ksadk/server/static/a2ui/common-types-v0_9.json +305 -0
- ksadk/server/static/a2ui/legacy-seven-components.json +230 -0
- ksadk/server/static/a2ui/manifest.json +86 -0
- ksadk/server/static/a2ui/material-icons-OFL-1.1.txt +93 -0
- ksadk/server/static/assets/{ArtifactsPanel-CILaW-fC.js → ArtifactsPanel-Cdr5C_vM.js} +1 -1
- ksadk/server/static/assets/{CodeBlock-BVrNVtJC.js → CodeBlock-BWRafud9.js} +6 -6
- ksadk/server/static/assets/{MathMessageMarkdown-Dp7c4wWD.js → MathMessageMarkdown-CFKeJIvy.js} +7 -7
- ksadk/server/static/assets/{MermaidBlock-Dxop8Rd7.js → MermaidBlock-BneAGUOd.js} +9 -9
- ksadk/server/static/assets/NativeTerminalPanel-BHI85zDO.js +1 -0
- ksadk/server/static/assets/OfficialA2uiRenderer-BOmT36lJ.js +16 -0
- ksadk/server/static/assets/{abnfDiagram-VCTEODGH-ckWDmOzw.js → abnfDiagram-VCTEODGH-DQvlOsBI.js} +1 -1
- ksadk/server/static/assets/{arc-DqxJede-.js → arc-CGx0e4pN.js} +1 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-CFWjFkDL.js +1 -0
- ksadk/server/static/assets/{architectureDiagram-5GKGNRK7-SEQA4bVi.js → architectureDiagram-5GKGNRK7-WyybcNKX.js} +1 -1
- ksadk/server/static/assets/{blockDiagram-NRAW4CY4-pM0B-6NJ.js → blockDiagram-NRAW4CY4-C9Cx_GVs.js} +1 -1
- ksadk/server/static/assets/{c4Diagram-UCG6FXSJ-m2tuCNVq.js → c4Diagram-UCG6FXSJ-Bh7X3bGr.js} +1 -1
- ksadk/server/static/assets/channel-D6Dp_l74.js +1 -0
- ksadk/server/static/assets/chunk-2Q5K7J3B-CwmjhFYK.js +1 -0
- ksadk/server/static/assets/{chunk-5VM5RSS4-GJHDr9Ww.js → chunk-5VM5RSS4-cP9XupZj.js} +1 -1
- ksadk/server/static/assets/{chunk-F27PBJKO-CbAN45AV.js → chunk-F27PBJKO-Bm77fvR9.js} +1 -1
- ksadk/server/static/assets/{chunk-G27WJ6UU-D5ngbbzF.js → chunk-G27WJ6UU-DDKNPesQ.js} +1 -1
- ksadk/server/static/assets/{chunk-JWPE2WC7-Cc5IwuYC.js → chunk-JWPE2WC7-BqiUDB7s.js} +1 -1
- ksadk/server/static/assets/{chunk-LCL6LL3I-CprgDDdJ.js → chunk-LCL6LL3I-C528mMZy.js} +1 -1
- ksadk/server/static/assets/{chunk-POPQ4Y6H-CDZhSy82.js → chunk-POPQ4Y6H-CzZ9g_Uf.js} +1 -1
- ksadk/server/static/assets/{chunk-RHFEMEQ7-CZchUNro.js → chunk-RHFEMEQ7-CXj4tUZ-.js} +1 -1
- ksadk/server/static/assets/{chunk-SVP7TREG-BVruqk6T.js → chunk-SVP7TREG-BHyd85pS.js} +1 -1
- ksadk/server/static/assets/{chunk-XXDRQBXY-4ld9SxPN.js → chunk-XXDRQBXY-Qe29PHGe.js} +1 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DsbvkCAV.js +1 -0
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DsbvkCAV.js +1 -0
- ksadk/server/static/assets/{cose-bilkent-JH36ORCC-Dmyyk_Vp.js → cose-bilkent-JH36ORCC-maRKgeec.js} +1 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-CBZRVuc4.js +1 -0
- ksadk/server/static/assets/{cynefinDiagram-5FMLGOSQ-BIyq3EJb.js → cynefinDiagram-5FMLGOSQ-CoD0bEvn.js} +1 -1
- ksadk/server/static/assets/{dagre-3AP2YEHR-eBw08Qdk.js → dagre-3AP2YEHR-BkpgQqyW.js} +1 -1
- ksadk/server/static/assets/{dagre-DfvnEf45.js → dagre-BUaTFrYa.js} +1 -1
- ksadk/server/static/assets/{diagram-S7CK7UJ4-CUSrE3Mg.js → diagram-S7CK7UJ4-25HdTbjE.js} +1 -1
- ksadk/server/static/assets/{diagram-UQ7AKVKN-Dq5Zw2gy.js → diagram-UQ7AKVKN-KO-WqOIg.js} +1 -1
- ksadk/server/static/assets/{diagram-VSXAHHWV-DyUHfNwT.js → diagram-VSXAHHWV-B360BkDQ.js} +1 -1
- ksadk/server/static/assets/{diagram-VX7I27RA-CREmM89O.js → diagram-VX7I27RA-COr1Oqsg.js} +1 -1
- ksadk/server/static/assets/{diagram-Z3DM3KII-Dw9zhHUK.js → diagram-Z3DM3KII-CgaKrIwB.js} +1 -1
- ksadk/server/static/assets/{dist-AEv-vXf-.js → dist--HftQyp9.js} +1 -1
- ksadk/server/static/assets/{dist-pq-nD33R.js → dist-B3Jp5r1e.js} +1 -1
- ksadk/server/static/assets/{dist-cxTGfdqx.js → dist-BEbS8Bag.js} +1 -1
- ksadk/server/static/assets/{dist-BX_-FENW.js → dist-BQ116UdZ.js} +1 -1
- ksadk/server/static/assets/{dist-DDSyLEOX.js → dist-BoRn8a_t.js} +1 -1
- ksadk/server/static/assets/{dist-BBsYarrI.js → dist-Brbrdmff.js} +1 -1
- ksadk/server/static/assets/{dist-B8Myiet9.js → dist-Bsuusoi0.js} +1 -1
- ksadk/server/static/assets/{dist-DUxO0R99.js → dist-Bxcu8Ca0.js} +1 -1
- ksadk/server/static/assets/{dist-CVPau3tn.js → dist-By-MVndb.js} +1 -1
- ksadk/server/static/assets/{dist-lOy23y43.js → dist-C9BTMVwS.js} +1 -1
- ksadk/server/static/assets/{dist-C_qdxcSH.js → dist-CBo9AHUv.js} +1 -1
- ksadk/server/static/assets/{dist-bupkyEBZ.js → dist-CR61WJFC.js} +1 -1
- ksadk/server/static/assets/{dist-CHpW1BHj.js → dist-CwnkOyDn.js} +1 -1
- ksadk/server/static/assets/{dist-0uJ4tdx6.js → dist-CxIl4t92.js} +1 -1
- ksadk/server/static/assets/{dist-Cp2PaOMY.js → dist-DKG0OYnk.js} +1 -1
- ksadk/server/static/assets/{dist-BQMrUwdI.js → dist-DSw5Ju6-.js} +1 -1
- ksadk/server/static/assets/{dist-hL5p1til.js → dist-DXOlCAay.js} +1 -1
- ksadk/server/static/assets/{dist-CD4L6ymH.js → dist-DgJ57sRe.js} +1 -1
- ksadk/server/static/assets/{dist-CuR5Bgme.js → dist-DmWw0IXB.js} +1 -1
- ksadk/server/static/assets/{dist-Co68Apq4.js → dist-DzdXSBJb.js} +1 -1
- ksadk/server/static/assets/{dist-B49GzZDb.js → dist-HHvdjADB.js} +1 -1
- ksadk/server/static/assets/{dist-QzbGrED_.js → dist-_0Xgu_07.js} +1 -1
- ksadk/server/static/assets/{ebnfDiagram-PWID7BFC-BS5LdNoR.js → ebnfDiagram-PWID7BFC-DogDP2db.js} +1 -1
- ksadk/server/static/assets/{erDiagram-SSCWMZ5O-Bv1QtiY-.js → erDiagram-SSCWMZ5O-CeBDnUjR.js} +1 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-vXZWMkpn.js +1 -0
- ksadk/server/static/assets/flowDiagram-A5DVABFB-5LRgzKLv.js +1 -0
- ksadk/server/static/assets/{ganttDiagram-EL5Y4UJY-musi-e0G.js → ganttDiagram-EL5Y4UJY-oIQL3MCp.js} +1 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-BUWSkncI.js +1 -0
- ksadk/server/static/assets/{gitGraphDiagram-WWUBYQGX-DH37EGkG.js → gitGraphDiagram-WWUBYQGX-B7qz0cmZ.js} +1 -1
- ksadk/server/static/assets/index-4g1ndaxW.js +1132 -0
- ksadk/server/static/assets/index-DEVfafsU.css +2 -0
- ksadk/server/static/assets/info-A6RAGUB7-CzJ_YrOs.js +1 -0
- ksadk/server/static/assets/{infoDiagram-RXCK75RN-C1kEtv2y.js → infoDiagram-RXCK75RN-yQRC41Ya.js} +1 -1
- ksadk/server/static/assets/{ishikawaDiagram-5VMMS53U-BCNPyMka.js → ishikawaDiagram-5VMMS53U-BCu4HiwL.js} +1 -1
- ksadk/server/static/assets/{journeyDiagram-EYS64GPL--cDbKnjP.js → journeyDiagram-EYS64GPL-JaqmO73K.js} +1 -1
- ksadk/server/static/assets/{kanban-definition-3QL26DDD-R1rAVw2f.js → kanban-definition-3QL26DDD-DQo4X8NO.js} +1 -1
- ksadk/server/static/assets/{katex-BT-X-V7U.js → katex-t_DWylQw.js} +1 -1
- ksadk/server/static/assets/{linear-DTR631iG.js → linear-DWdnI35B.js} +1 -1
- ksadk/server/static/assets/material-icons-latin-400-normal-kAwBdRge.woff2 +0 -0
- ksadk/server/static/assets/{mermaid-parser.core-DfFzJhX8.js → mermaid-parser.core-BHrT2Pfe.js} +2 -2
- ksadk/server/static/assets/{mindmap-definition-FBJOCRG2-D4by_rmk.js → mindmap-definition-FBJOCRG2-PBVAhZYV.js} +1 -1
- ksadk/server/static/assets/packet-AYTQ26CC-CXoos6fx.js +1 -0
- ksadk/server/static/assets/{pegDiagram-XKGWAZYB-xWXPEh0c.js → pegDiagram-XKGWAZYB-CU_cLfow.js} +1 -1
- ksadk/server/static/assets/pie-WAS4IAKB-CjF9NoIt.js +1 -0
- ksadk/server/static/assets/{pieDiagram-E7YTZNPT-BudBDlCI.js → pieDiagram-E7YTZNPT-B1h0-_pW.js} +1 -1
- ksadk/server/static/assets/{quadrantDiagram-AXDQQJYC-DXZ0PCJF.js → quadrantDiagram-AXDQQJYC-DEMoGo5a.js} +1 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BQGWs9nw.js +1 -0
- ksadk/server/static/assets/railroad-74A4TZTK-B6znvLUK.js +1 -0
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-Bzquz0As.js +1 -0
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-1IikGkb5.js +1 -0
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-BKKgHzdc.js +1 -0
- ksadk/server/static/assets/{railroadDiagram-O6MQD6OU-BdAYRYB8.js → railroadDiagram-O6MQD6OU-BTAob2wg.js} +1 -1
- ksadk/server/static/assets/{requirementDiagram-EFPCY7ZU-CBBmaL70.js → requirementDiagram-EFPCY7ZU-Dl0Q2SuO.js} +1 -1
- ksadk/server/static/assets/{sankeyDiagram-P5KCCOFB-Doc3rdwp.js → sankeyDiagram-P5KCCOFB-DeaTWkur.js} +1 -1
- ksadk/server/static/assets/{sequenceDiagram-WJ2MYXX4-0J8R8hWW.js → sequenceDiagram-WJ2MYXX4-gFQYrsOd.js} +1 -1
- ksadk/server/static/assets/{sizeCapture-X5ZJPWSS-CfFLlWsK.js → sizeCapture-X5ZJPWSS-pGQzddMB.js} +1 -1
- ksadk/server/static/assets/{stateDiagram-HBIQ2CUA-jBwkjtTy.js → stateDiagram-HBIQ2CUA-DmpYOZt1.js} +1 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Dolxgkw3.js +1 -0
- ksadk/server/static/assets/{swimlanes-XN3QIQJK-B0WxTQf8.js → swimlanes-XN3QIQJK-BfuSAsrr.js} +1 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-BuI1erYj.js +8 -0
- ksadk/server/static/assets/{timeline-definition-24CTP7MA-BfCT_75A.js → timeline-definition-24CTP7MA-CgJwrrxf.js} +1 -1
- ksadk/server/static/assets/treeView-Q6P3EWNA-DtMdDH8N.js +1 -0
- ksadk/server/static/assets/treemap-WGGIJYW6-VoU8QtLZ.js +1 -0
- ksadk/server/static/assets/{vennDiagram-4TSXK5OY-9gX1VMDC.js → vennDiagram-4TSXK5OY-CBSAgXDd.js} +1 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-YWSRB0Zm.js +1 -0
- ksadk/server/static/assets/{wardleyDiagram-VM6X3IG4-sEs_BP6O.js → wardleyDiagram-VM6X3IG4-013TZ2JZ.js} +1 -1
- ksadk/server/static/assets/{xychartDiagram-S5SC5T6Z-Ll4jvUN9.js → xychartDiagram-S5SC5T6Z-u6Frp8xp.js} +1 -1
- ksadk/server/static/index.html +2 -2
- ksadk/server/static/ui-source.json +11 -0
- ksadk/sessions/_local_service_sync.py +146 -5
- ksadk/sessions/_postgres_schema.py +17 -0
- ksadk/sessions/base.py +3 -0
- ksadk/sessions/continuity.py +7 -1
- ksadk/sessions/db_budget.py +14 -12
- ksadk/sessions/history_budget.py +7 -0
- ksadk/sessions/in_memory.py +113 -4
- ksadk/sessions/persistence.py +73 -7
- ksadk/sessions/postgres_service.py +948 -8
- ksadk/sessions/resilience.py +16 -0
- ksadk/sessions/resilient.py +601 -5
- ksadk/sessions/topology.py +9 -2
- ksadk/skills/mcp_server/register.py +471 -415
- ksadk/skills/mcp_server/server.py +239 -217
- ksadk/skills/request_connection.py +188 -0
- ksadk/skills/runtime/backends/e2b.py +52 -12
- ksadk/skills/service_client.py +104 -45
- ksadk/studio/api.py +413 -11
- ksadk/studio/api_contracts.py +7 -3
- ksadk/studio/api_plugin_routes.py +13 -6
- ksadk/studio/authoring_coordinator.py +6 -1
- ksadk/studio/background_output.py +72 -0
- ksadk/studio/build_resolution.py +28 -4
- ksadk/studio/cloud.py +516 -7
- ksadk/studio/cloud_history.py +149 -0
- ksadk/studio/cloud_shared_web.py +32 -3
- ksadk/studio/compiler.py +93 -4
- ksadk/studio/contracts.py +376 -9
- ksadk/studio/dsh_application.py +17 -4
- ksadk/studio/execution_host.py +10 -5
- ksadk/studio/interaction_submission.py +7 -2
- ksadk/studio/mcp_runtime.py +23 -8
- ksadk/studio/model_chat_tools.py +22 -10
- ksadk/studio/model_client.py +41 -11
- ksadk/studio/model_wire_identity.py +24 -0
- ksadk/studio/native_background_command_port.py +97 -0
- ksadk/studio/native_background_connection.py +230 -0
- ksadk/studio/native_background_locator.py +272 -0
- ksadk/studio/native_background_ownership.py +255 -0
- ksadk/studio/native_background_wakeup.py +686 -0
- ksadk/studio/native_browser_port.py +9 -3
- ksadk/studio/native_child_skills.py +4 -0
- ksadk/studio/native_coding_template.py +287 -0
- ksadk/studio/native_command_policy.py +23 -0
- ksadk/studio/native_context_evidence.py +81 -0
- ksadk/studio/native_context_port.py +13 -2
- ksadk/studio/native_directory_observation.py +177 -0
- ksadk/studio/native_final_shape.py +148 -19
- ksadk/studio/native_mcp_disclosure.py +8 -6
- ksadk/studio/native_mcp_tool_port.py +3 -1
- ksadk/studio/native_memory_context.py +10 -8
- ksadk/studio/native_model_port.py +201 -43
- ksadk/studio/native_planning.py +43 -2
- ksadk/studio/native_product.py +237 -12
- ksadk/studio/native_project_instructions.py +267 -0
- ksadk/studio/native_read_budget.py +21 -3
- ksadk/studio/native_subagent_port.py +125 -2
- ksadk/studio/native_tool_port.py +255 -14
- ksadk/studio/native_verification_presentation.py +13 -3
- ksadk/studio/plugin_composition.py +8 -1
- ksadk/studio/plugin_kernel_adapter.py +13 -0
- ksadk/studio/plugin_native_activation.py +6 -4
- ksadk/studio/plugin_runtime.py +9 -0
- ksadk/studio/presentation.py +12 -0
- ksadk/studio/project_instruction_trust.py +54 -0
- ksadk/studio/repository.py +1 -1
- ksadk/studio/resource_catalog.py +4 -1
- ksadk/studio/run_activity.py +8 -0
- ksadk/studio/run_service.py +496 -40
- ksadk/studio/scheduler_assistant.py +3 -1
- ksadk/studio/service.py +101 -2
- ksadk/studio/shared_web.py +38 -12
- ksadk/studio/shared_web_response_events.py +32 -5
- ksadk/studio/static/assets/ChannelsPage-Do_mRmVu.js +8 -0
- ksadk/studio/static/assets/{CodeBlock-DMIf4h33-CkufcPYo.js → CodeBlock-DMIf4h33-CsO7rJKv.js} +3 -3
- ksadk/studio/static/assets/{ExecutionTree-v3HexvPo-Bk8wzGSy.js → ExecutionTree-v3HexvPo-BeWoMqA-.js} +1 -1
- ksadk/studio/static/assets/{MathMessageMarkdown-BesSeCYl-DYG1Wzbx.js → MathMessageMarkdown-BesSeCYl-CiB60plG.js} +1 -1
- ksadk/studio/static/assets/{MermaidBlock-H_0qzQDf-BdXtxug_.js → MermaidBlock-H_0qzQDf-oRTZUNRr.js} +3 -3
- ksadk/studio/static/assets/{MessageMarkdown-CwMTvgFj-BeyLyQHu.js → MessageMarkdown-CwMTvgFj-BzEmQkHH.js} +5 -5
- ksadk/studio/static/assets/OfficialA2uiRenderer-DI49Kpxu-BBxfdj3P.js +16 -0
- ksadk/studio/static/assets/{PrismRenderer-5pK6tUdb.js → PrismRenderer-CcrOV6Lf.js} +1 -1
- ksadk/studio/static/assets/TeamsPage-qNVYpcox.js +4 -0
- ksadk/studio/static/assets/{abnfDiagram-VCTEODGH-Bnb1O3tA.js → abnfDiagram-VCTEODGH-BdEjkX5G.js} +1 -1
- ksadk/studio/static/assets/{arc-Pry-7G1_.js → arc-4LNeT6Qr.js} +1 -1
- ksadk/studio/static/assets/architecture-7GRP2DOG-C6BmiLXs.js +1 -0
- ksadk/studio/static/assets/{architectureDiagram-5GKGNRK7-5Zn1gqJv.js → architectureDiagram-5GKGNRK7-nKXkceF2.js} +3 -3
- ksadk/studio/static/assets/{blockDiagram-I7D4REHJ-CLB4L11u.js → blockDiagram-I7D4REHJ-pSawBX0F.js} +1 -1
- ksadk/studio/static/assets/{c4Diagram-7LVT6UL2-BOma_Z_F.js → c4Diagram-7LVT6UL2-D3DGtCIa.js} +1 -1
- ksadk/studio/static/assets/channel-CwBcaXYb.js +1 -0
- ksadk/studio/static/assets/{chunk-2E4U76K2-BFf_huql.js → chunk-2E4U76K2-CfUBZPB8.js} +2 -2
- ksadk/studio/static/assets/chunk-2Q5K7J3B-B9fZb2AW.js +1 -0
- ksadk/studio/static/assets/{chunk-2ZTRR5NV-C2qZJila.js → chunk-2ZTRR5NV-63jTqPgP.js} +1 -1
- ksadk/studio/static/assets/{chunk-3Z5EZCMW-DMniOlPd.js → chunk-3Z5EZCMW-CLzTC-ds.js} +1 -1
- ksadk/studio/static/assets/{chunk-4HAMMTFA-DVtDP4rm.js → chunk-4HAMMTFA--k1euiK8.js} +3 -3
- ksadk/studio/static/assets/{chunk-5V3GS4D5-i-ZDOEnP.js → chunk-5V3GS4D5--NT8dMSC.js} +1 -1
- ksadk/studio/static/assets/{chunk-5VM5RSS4-ZNzvKenW.js → chunk-5VM5RSS4-B4EX-xPG.js} +2 -2
- ksadk/studio/static/assets/{chunk-6AZGARVD-BB6FqMl-.js → chunk-6AZGARVD-BxyCuIKr.js} +1 -1
- ksadk/studio/static/assets/{chunk-6EIED4P4-DdUJkP0f.js → chunk-6EIED4P4-BqAnqs6L.js} +1 -1
- ksadk/studio/static/assets/{chunk-6K3QC6MW-CqVsVn-y.js → chunk-6K3QC6MW-DqKCc1_c.js} +1 -1
- ksadk/studio/static/assets/{chunk-6TQVIW2G-DKlLbNIP.js → chunk-6TQVIW2G-NQp6TssR.js} +1 -1
- ksadk/studio/static/assets/{chunk-747NJXEK-BFkZPlab.js → chunk-747NJXEK-CFf3ol0D.js} +1 -1
- ksadk/studio/static/assets/{chunk-75Z2AOVW-BZNhM4vB.js → chunk-75Z2AOVW-DpzsVI3p.js} +1 -1
- ksadk/studio/static/assets/chunk-CLGD4ZFX-BiEFihjn.js +1 -0
- ksadk/studio/static/assets/{chunk-DU6HZSFF-CpEZCUgg.js → chunk-DU6HZSFF-HbWKkMwX.js} +3 -3
- ksadk/studio/static/assets/{chunk-F27PBJKO-D7pvKf0C.js → chunk-F27PBJKO-BY9pwz0W.js} +1 -1
- ksadk/studio/static/assets/{chunk-FOHPRMQF-DHwB1DNv.js → chunk-FOHPRMQF-BAABtQ6R.js} +5 -5
- ksadk/studio/static/assets/{chunk-GMAD6QVW-DE_8H717.js → chunk-GMAD6QVW-C-Lw1ag9.js} +1 -1
- ksadk/studio/static/assets/{chunk-GVQU2GXP-BfEB0lNv.js → chunk-GVQU2GXP-CCUMaVF8.js} +1 -1
- ksadk/studio/static/assets/{chunk-I5DQTOEV-Hm2LfiYI.js → chunk-I5DQTOEV-DpUJ7zEH.js} +1 -1
- ksadk/studio/static/assets/{chunk-ICYGCRZG-749o-pGJ.js → chunk-ICYGCRZG-CknVx2uG.js} +1 -1
- ksadk/studio/static/assets/{chunk-IH6LHLGP-CC6I9F3i.js → chunk-IH6LHLGP-BJ6nT6RF.js} +1 -1
- ksadk/studio/static/assets/{chunk-IMKFNOWR-D38axYOR.js → chunk-IMKFNOWR-CTelL5KO.js} +1 -1
- ksadk/studio/static/assets/{chunk-JWPE2WC7-DVXcaiue.js → chunk-JWPE2WC7-CMg2kMrr.js} +1 -1
- ksadk/studio/static/assets/{chunk-KI3K4JFJ-Rma-0k_M.js → chunk-KI3K4JFJ-B1SKa0PC.js} +1 -1
- ksadk/studio/static/assets/{chunk-L3NEJ4N5-Dq5xn7aL.js → chunk-L3NEJ4N5-C8A22muD.js} +1 -1
- ksadk/studio/static/assets/{chunk-LNGE3PJU-DWpGwHrW.js → chunk-LNGE3PJU-D_NJe87O.js} +1 -1
- ksadk/studio/static/assets/{chunk-OSK3NFVY-DiCQjx9b.js → chunk-OSK3NFVY-DFHvKoNt.js} +1 -1
- ksadk/studio/static/assets/{chunk-OUJLGHUK-D0j2JRSg.js → chunk-OUJLGHUK-DkHSrVKj.js} +1 -1
- ksadk/studio/static/assets/{chunk-P2QGCYS3-VdhKmfYq.js → chunk-P2QGCYS3-C3nH7MEr.js} +1 -1
- ksadk/studio/static/assets/{chunk-POPQ4Y6H-C1_rzO5M.js → chunk-POPQ4Y6H-CLm6A2JW.js} +1 -1
- ksadk/studio/static/assets/{chunk-PWAF6VOD-B45HvflI.js → chunk-PWAF6VOD-BmVQq92D.js} +1 -1
- ksadk/studio/static/assets/{chunk-SHT3W25Y-DsCFnRVE.js → chunk-SHT3W25Y-cETj_Yg7.js} +1 -1
- ksadk/studio/static/assets/{chunk-SVP7TREG-DljApgRX.js → chunk-SVP7TREG-hm4Ur8KN.js} +1 -1
- ksadk/studio/static/assets/{chunk-TICWLB2K-DWqRtyqa.js → chunk-TICWLB2K-BuVjFGjc.js} +1 -1
- ksadk/studio/static/assets/{chunk-TLUHSLCS-DUeGgnD5.js → chunk-TLUHSLCS-7mZ4xr0q.js} +2 -2
- ksadk/studio/static/assets/{chunk-UY3FDG6J-CnmaAkG5.js → chunk-UY3FDG6J-2nV2i5mW.js} +1 -1
- ksadk/studio/static/assets/{chunk-XHIXRSVI-BFQ6B8BE.js → chunk-XHIXRSVI-BIR36bKX.js} +1 -1
- ksadk/studio/static/assets/chunk-XXDRQBXY-rafYnJzG.js +1 -0
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-DdyoXyMk.js +1 -0
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-DdyoXyMk.js +1 -0
- ksadk/studio/static/assets/{cose-bilkent-JH36ORCC-om8AY0Mc.js → cose-bilkent-JH36ORCC-B9Ubz7rk.js} +1 -1
- ksadk/studio/static/assets/{createLucideIcon-DR0LGTP5.js → createLucideIcon-CTD6_IjT.js} +1 -1
- ksadk/studio/static/assets/cynefin-OW5HDTMX-BVS4hy6V.js +1 -0
- ksadk/studio/static/assets/{cynefinDiagram-5FMLGOSQ-6BrmK52S.js → cynefinDiagram-5FMLGOSQ-CKrgw1wI.js} +1 -1
- ksadk/studio/static/assets/{cytoscape.esm-CGd-uY3x.js → cytoscape.esm-Jip0ihto.js} +16 -16
- ksadk/studio/static/assets/{dagre-GXQ25YYZ-buZBRlwz.js → dagre-GXQ25YYZ-NjDjs3Kl.js} +1 -1
- ksadk/studio/static/assets/{dagre-PrKaheQc.js → dagre-YnTFOVV4.js} +1 -1
- ksadk/studio/static/assets/{diagram-S7CK7UJ4-C6aH78c4.js → diagram-S7CK7UJ4-C6X87QRZ.js} +1 -1
- ksadk/studio/static/assets/{diagram-UQ7AKVKN-DY_tQ6C_.js → diagram-UQ7AKVKN-Xf2JVuyK.js} +1 -1
- ksadk/studio/static/assets/{diagram-VSXAHHWV-DX9p5cQT.js → diagram-VSXAHHWV-CUZlU7Dr.js} +1 -1
- ksadk/studio/static/assets/{diagram-VX7I27RA-DB2WSH8X.js → diagram-VX7I27RA-BOcfFxfe.js} +1 -1
- ksadk/studio/static/assets/{diagram-Z3DM3KII-Ce1BJwHE.js → diagram-Z3DM3KII-1zrr7ezR.js} +1 -1
- ksadk/studio/static/assets/{dist-v5Q1xZ2K.js → dist-Brlz61T5.js} +1 -1
- ksadk/studio/static/assets/{ebnfDiagram-PWID7BFC-Daukxwqf.js → ebnfDiagram-PWID7BFC-C1LymnKg.js} +1 -1
- ksadk/studio/static/assets/{erDiagram-RLTQ6QDP-CGthTMmJ.js → erDiagram-RLTQ6QDP-Dm0YWPea.js} +1 -1
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-D9gMNzTL.js +1 -0
- ksadk/studio/static/assets/flowDiagram-HODETNUW-NYJgBJQu.js +1 -0
- ksadk/studio/static/assets/{ganttDiagram-EL5Y4UJY-BfoAZW9X.js → ganttDiagram-EL5Y4UJY-uJ27IKEw.js} +1 -1
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-DQVCMicu.js +1 -0
- ksadk/studio/static/assets/{gitGraphDiagram-WWUBYQGX-S985OIJF.js → gitGraphDiagram-WWUBYQGX-mtpvi7ne.js} +3 -3
- ksadk/studio/static/assets/index-Cp9Unfkn.css +2 -0
- ksadk/studio/static/assets/index-HepnaEeR.js +1152 -0
- ksadk/studio/static/assets/{index.dom-BQenBtFm.js → index.dom-DSf_jcX2.js} +1 -1
- ksadk/studio/static/assets/info-A6RAGUB7-CMrsF9SP.js +1 -0
- ksadk/studio/static/assets/{infoDiagram-27XIBGKW-CO3W8tFn.js → infoDiagram-27XIBGKW-Hqrd2vbU.js} +1 -1
- ksadk/studio/static/assets/{ishikawaDiagram-5VMMS53U-BUGEl8cO.js → ishikawaDiagram-5VMMS53U-BB7nm3Dk.js} +1 -1
- ksadk/studio/static/assets/{journeyDiagram-3NMN7TZE-Ch2ZYxvr.js → journeyDiagram-3NMN7TZE-BXbRt7Ps.js} +1 -1
- ksadk/studio/static/assets/{kanban-definition-UXKFOSKX-Da-Fp4vC.js → kanban-definition-UXKFOSKX-2EtAxRbw.js} +1 -1
- ksadk/studio/static/assets/{katex-DhON-x74.js → katex-K_8DQ5UN.js} +1 -1
- ksadk/studio/static/assets/{line-BDaeq300.js → line-C4h80pWP.js} +1 -1
- ksadk/studio/static/assets/{linear-DmucvK78.js → linear-DCteYK3U.js} +1 -1
- ksadk/studio/static/assets/{mermaid-parser.core-Cj5mYdBi.js → mermaid-parser.core-TWhr-wg2.js} +2 -2
- ksadk/studio/static/assets/{mindmap-definition-YA3MSWOX-CvlsVQ38.js → mindmap-definition-YA3MSWOX-BC7jpEOt.js} +1 -1
- ksadk/studio/static/assets/{ordinal-BDEzSJ7C.js → ordinal-BXUrfsNY.js} +1 -1
- ksadk/studio/static/assets/packet-AYTQ26CC-BdMfjW7Z.js +1 -0
- ksadk/studio/static/assets/{pegDiagram-XKGWAZYB-BuHuNgT5.js → pegDiagram-XKGWAZYB-C-ZzWopk.js} +1 -1
- ksadk/studio/static/assets/pie-WAS4IAKB-B06bKgAM.js +1 -0
- ksadk/studio/static/assets/{pieDiagram-E7YTZNPT-DlrWiSOv.js → pieDiagram-E7YTZNPT-DGDL1XJp.js} +1 -1
- ksadk/studio/static/assets/{quadrantDiagram-AXDQQJYC-BA3hpUZM.js → quadrantDiagram-AXDQQJYC-DAPa64vy.js} +1 -1
- ksadk/studio/static/assets/radar-RG4KPBEZ-4lhecdYg.js +1 -0
- ksadk/studio/static/assets/railroad-74A4TZTK-CBTdV2Xq.js +1 -0
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-D4HzgxJY.js +1 -0
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-D-qRzoh8.js +1 -0
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-DYA99dLv.js +1 -0
- ksadk/studio/static/assets/{railroadDiagram-O6MQD6OU-BxpAazym.js → railroadDiagram-O6MQD6OU-CkH0b7UT.js} +1 -1
- ksadk/studio/static/assets/{react-vendor-BNmTiJ-I.js → react-vendor-CTyAWUMQ.js} +1 -1
- ksadk/studio/static/assets/{requirementDiagram-BXWQKSXE-E-Ge0FcV.js → requirementDiagram-BXWQKSXE-BgZ0H8ni.js} +2 -2
- ksadk/studio/static/assets/rolldown-runtime-cO0ylGnt.js +1 -0
- ksadk/studio/static/assets/{sankeyDiagram-P5KCCOFB-CA6YKhQ3.js → sankeyDiagram-P5KCCOFB-BgqqGK6v.js} +1 -1
- ksadk/studio/static/assets/{sequenceDiagram-WJ2MYXX4-CcElXGg4.js → sequenceDiagram-WJ2MYXX4-CbQE1ava.js} +1 -1
- ksadk/studio/static/assets/{sizeCapture-INFHLROL-B0uUizjq.js → sizeCapture-INFHLROL-BtEJ4_JN.js} +1 -1
- ksadk/studio/static/assets/{src-B6xuSHsQ.js → src-DSHesKRm.js} +1 -1
- ksadk/studio/static/assets/{stateDiagram-D77RDMKH-DdXZOFqY.js → stateDiagram-D77RDMKH-D9uG2y8U.js} +1 -1
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-2pITMnQn.js +1 -0
- ksadk/studio/static/assets/{swimlanes-42K2YHIH-NtgEEHLY.js → swimlanes-42K2YHIH-B0QgwqLd.js} +1 -1
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-TXD08-JZ.js +8 -0
- ksadk/studio/static/assets/{timeline-definition-24CTP7MA-CIuYhNy3.js → timeline-definition-24CTP7MA-tbRyDWb4.js} +1 -1
- ksadk/studio/static/assets/treeView-Q6P3EWNA-NawrivXx.js +1 -0
- ksadk/studio/static/assets/treemap-WGGIJYW6-DabVcIU4.js +1 -0
- ksadk/studio/static/assets/{vennDiagram-4TSXK5OY-7HbApbrv.js → vennDiagram-4TSXK5OY-Xjhys4e4.js} +1 -1
- ksadk/studio/static/assets/wardley-WFR3VGLG-BrU5uhdd.js +1 -0
- ksadk/studio/static/assets/{wardleyDiagram-VM6X3IG4-CMJiaedy.js → wardleyDiagram-VM6X3IG4--sd605zd.js} +1 -1
- ksadk/studio/static/assets/{xychartDiagram-S5SC5T6Z-BdgtMvW2.js → xychartDiagram-S5SC5T6Z-B3XzcsnZ.js} +1 -1
- ksadk/studio/static/index.html +9 -9
- ksadk/studio/static/ui-source.json +11 -0
- ksadk/studio/teams_installation.py +1 -1
- ksadk/studio/templates.py +33 -3
- ksadk/toolsets/__init__.py +14 -1
- ksadk/toolsets/sandbox.py +303 -7
- ksadk/toolsets/workspace.py +17 -10
- ksadk/toolsets/workspace_editing.py +40 -0
- ksadk/toolsets/workspace_model_observation.py +6 -1
- ksadk/tracing/__init__.py +10 -1
- ksadk/tracing/routed.py +416 -0
- ksadk/tracing/setup.py +111 -6
- ksadk/tunnel/__init__.py +37 -0
- ksadk/tunnel/connector.py +384 -0
- ksadk/tunnel/discovery.py +107 -0
- ksadk/tunnel/failure.py +168 -0
- ksadk/tunnel/http_tools.py +100 -0
- ksadk/tunnel/langgraph.py +125 -0
- ksadk/tunnel/middleware.py +28 -0
- ksadk/tunnel/peers.py +872 -0
- ksadk/tunnel/protocol.py +97 -0
- ksadk/tunnel/registry.py +306 -0
- ksadk/tunnel/runtime.py +147 -0
- ksadk/tunnel/server.py +201 -0
- ksadk/tunnel/services.py +366 -0
- ksadk/tunnel/toolset.py +78 -0
- ksadk/version.py +1 -1
- ksadk_runtime_common/memory_backend/manifest.py +1 -1
- ksadk_runtime_common/memory_backend/providers/ksmem.py +60 -0
- ksadk_runtime_common/memory_backend/providers/lancedb.py +1 -2
- ksadk_runtime_common/memory_backend/providers/mem0.py +21 -0
- ksadk_runtime_common/memory_backend/registry.py +2 -0
- ksadk_runtime_common/memory_backend/render.py +1 -1
- ksadk_runtime_common/schemas/memory_backend_manifest.schema.json +37 -12
- ksadk_runtime_common/schemas/runtime_event_v2.json +2 -1
- ksadk/server/static/assets/NativeTerminalPanel-Cjjz8B30.js +0 -1
- ksadk/server/static/assets/architecture-7GRP2DOG-pn_DuLy6.js +0 -1
- ksadk/server/static/assets/channel-fySsnkft.js +0 -1
- ksadk/server/static/assets/chunk-2Q5K7J3B-BheGxKRQ.js +0 -1
- ksadk/server/static/assets/classDiagram-DTDB5LWJ-DSfLtNYm.js +0 -1
- ksadk/server/static/assets/classDiagram-v2-JRS7N3AN-DSfLtNYm.js +0 -1
- ksadk/server/static/assets/cynefin-OW5HDTMX-PFWIGtvA.js +0 -1
- ksadk/server/static/assets/eventmodeling-NTZA5JFV-DsM4upQX.js +0 -1
- ksadk/server/static/assets/flowDiagram-A5DVABFB-D5NA16k9.js +0 -1
- ksadk/server/static/assets/gitGraph-4MIJSDKK-DUCVz-ih.js +0 -1
- ksadk/server/static/assets/index-CZdkAvsv.js +0 -244
- ksadk/server/static/assets/index-CvXdHgF3.css +0 -2
- ksadk/server/static/assets/info-A6RAGUB7-rw0ZNHZp.js +0 -1
- ksadk/server/static/assets/packet-AYTQ26CC-Ca4Hvki9.js +0 -1
- ksadk/server/static/assets/pie-WAS4IAKB-hwiz6fbw.js +0 -1
- ksadk/server/static/assets/radar-RG4KPBEZ-BR1oZXLM.js +0 -1
- ksadk/server/static/assets/railroad-74A4TZTK-DfgEISfX.js +0 -1
- ksadk/server/static/assets/railroad-abnf-HS5TGJTU-CWOC3rdk.js +0 -1
- ksadk/server/static/assets/railroad-ebnf-LZEXJU2U-CiRvHCLY.js +0 -1
- ksadk/server/static/assets/railroad-peg-WCYAUIDC-DSDDyJ2f.js +0 -1
- ksadk/server/static/assets/stateDiagram-v2-4QOOHH4V-Cw1fPb5w.js +0 -1
- ksadk/server/static/assets/swimlanesDiagram-VK2B7HYN-Cc3JMBAF.js +0 -8
- ksadk/server/static/assets/treeView-Q6P3EWNA-C05SJHxo.js +0 -1
- ksadk/server/static/assets/treemap-WGGIJYW6-BqNLAhc3.js +0 -1
- ksadk/server/static/assets/wardley-WFR3VGLG-DokNktqB.js +0 -1
- ksadk/studio/static/assets/ChannelsPage-xX5HlMId.js +0 -8
- ksadk/studio/static/assets/TeamsPage-CCaaGaVp.js +0 -3
- ksadk/studio/static/assets/architecture-7GRP2DOG-BMOPAkUC.js +0 -1
- ksadk/studio/static/assets/channel-r8itPEik.js +0 -1
- ksadk/studio/static/assets/chunk-2Q5K7J3B-C1jixKkw.js +0 -1
- ksadk/studio/static/assets/chunk-CLGD4ZFX-D-GTtyKs.js +0 -1
- ksadk/studio/static/assets/chunk-XXDRQBXY-DqAYeljN.js +0 -1
- ksadk/studio/static/assets/classDiagram-ZZMXUADV-DjeMNJmu.js +0 -1
- ksadk/studio/static/assets/classDiagram-v2-VYDZK3BY-DjeMNJmu.js +0 -1
- ksadk/studio/static/assets/cynefin-OW5HDTMX-7tP7QfM3.js +0 -1
- ksadk/studio/static/assets/eventmodeling-NTZA5JFV-BR2FzK4R.js +0 -1
- ksadk/studio/static/assets/flowDiagram-HODETNUW-CZ1tEenp.js +0 -1
- ksadk/studio/static/assets/gitGraph-4MIJSDKK-DYlXv_yJ.js +0 -1
- ksadk/studio/static/assets/index-C7DNDik2.css +0 -2
- ksadk/studio/static/assets/index-Cy68gTlH.js +0 -265
- ksadk/studio/static/assets/info-A6RAGUB7-BlU-8_xu.js +0 -1
- ksadk/studio/static/assets/packet-AYTQ26CC-BSJEH9Lb.js +0 -1
- ksadk/studio/static/assets/pie-WAS4IAKB-qxv01Y8W.js +0 -1
- ksadk/studio/static/assets/radar-RG4KPBEZ-B6h6pWOs.js +0 -1
- ksadk/studio/static/assets/railroad-74A4TZTK-CGtTWdGc.js +0 -1
- ksadk/studio/static/assets/railroad-abnf-HS5TGJTU-Cq7y22IA.js +0 -1
- ksadk/studio/static/assets/railroad-ebnf-LZEXJU2U-V0aQVv9m.js +0 -1
- ksadk/studio/static/assets/railroad-peg-WCYAUIDC-BQiIsX_p.js +0 -1
- ksadk/studio/static/assets/rolldown-runtime-hePW80VL.js +0 -1
- ksadk/studio/static/assets/stateDiagram-v2-MP3YSRHH-CJbOM-QK.js +0 -1
- ksadk/studio/static/assets/swimlanesDiagram-VR7AAH4N-D-AVlW8B.js +0 -8
- ksadk/studio/static/assets/treeView-Q6P3EWNA-BTTYcvrF.js +0 -1
- ksadk/studio/static/assets/treemap-WGGIJYW6-Cg7tyfH8.js +0 -1
- ksadk/studio/static/assets/wardley-WFR3VGLG-C6N1rULY.js +0 -1
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.8.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.8.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.8.dist-info}/top_level.txt +0 -0
- /ksadk/studio/static/assets/{array-BifhSqXX.js → array-mTkv7xdZ.js} +0 -0
- /ksadk/studio/static/assets/{chunk-Y2CYZVJY-DsF7k-Jl.js → chunk-Y2CYZVJY-C72YQVBQ.js} +0 -0
- /ksadk/studio/static/assets/{clsx-DB0hHKMi.js → clsx-BE-4uLAX.js} +0 -0
- /ksadk/studio/static/assets/{defaultLocale-BFoDCU3G.js → defaultLocale-YBltSZ3l.js} +0 -0
- /ksadk/studio/static/assets/{graphlib-DS17s2tU.js → graphlib-CYZB3_li.js} +0 -0
- /ksadk/studio/static/assets/{init-C-OQMol4.js → init-Ccnd9r3c.js} +0 -0
- /ksadk/studio/static/assets/{path-fybaL0A-.js → path-BfzAkHoX.js} +0 -0
- /ksadk/studio/static/assets/{preload-helper-CO68xz6u.js → preload-helper-2TpOpXko.js} +0 -0
- /ksadk/studio/static/assets/{presentation-yYw7xK60-BmcZriri.js → presentation-yYw7xK60-B7PYgYAE.js} +0 -0
- /ksadk/studio/static/assets/{rolldown-runtime-Dy4uBu1J-DK3Fl9T5.js → rolldown-runtime-Dy4uBu1J-CmRlGT1x.js} +0 -0
- /ksadk/studio/static/assets/{rough.esm-Dy-Kn_BL.js → rough.esm-BF6Sy8cM.js} +0 -0
ksadk/kernel/bootstrap.py
CHANGED
|
@@ -24,15 +24,15 @@ from __future__ import annotations
|
|
|
24
24
|
import asyncio
|
|
25
25
|
import hashlib
|
|
26
26
|
import logging
|
|
27
|
-
import os
|
|
28
27
|
import time
|
|
28
|
+
from bisect import bisect_right
|
|
29
29
|
from collections.abc import Callable
|
|
30
30
|
from dataclasses import dataclass, field
|
|
31
|
-
from
|
|
32
|
-
from
|
|
31
|
+
from typing import Any
|
|
32
|
+
from uuid import uuid4
|
|
33
33
|
|
|
34
34
|
from ksadk.events.session_event import SessionServiceEventStore
|
|
35
|
-
from ksadk.kernel.authorization import AgentControlPermitVerifier
|
|
35
|
+
from ksadk.kernel.authorization import AgentControlPermitVerifier
|
|
36
36
|
from ksadk.kernel.contract_fingerprints import (
|
|
37
37
|
AGENT_KERNEL_V1_AGGREGATE_DIGEST,
|
|
38
38
|
runtime_capability_admission_digest,
|
|
@@ -42,70 +42,23 @@ from ksadk.kernel.contracts import RuntimeCapabilityMatrix
|
|
|
42
42
|
from ksadk.kernel.control import AgentKernel, default_capability_matrix
|
|
43
43
|
from ksadk.kernel.errors import InvalidCommandError, StaleFenceError
|
|
44
44
|
from ksadk.kernel.recovery import RecoveryCoordinator
|
|
45
|
+
from ksadk.kernel.runtime_config import AgentKernelRuntimeConfig
|
|
45
46
|
from ksadk.kernel.runtime_identity import runtime_identity
|
|
46
|
-
from ksadk.kernel.store import AgentKernelStore
|
|
47
|
+
from ksadk.kernel.store import AgentKernelStore
|
|
47
48
|
from ksadk.kernel.worker import AgentKernelWorker
|
|
48
49
|
from ksadk.runtime.adapter import RuntimeAdapter
|
|
49
|
-
|
|
50
|
-
from ksadk.kernel.readiness import AgentKernelReadiness
|
|
51
|
-
|
|
52
|
-
AuthorityMode = Literal["local", "hosted"]
|
|
53
|
-
DurabilityTier = Literal["durable", "ephemeral"]
|
|
50
|
+
from ksadk.sessions.resilience import is_transient_session_backend_failure
|
|
54
51
|
|
|
55
52
|
logger = logging.getLogger(__name__)
|
|
56
53
|
MAX_CONCURRENT_KERNEL_SESSIONS = 64
|
|
57
54
|
|
|
58
55
|
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
driver: str = "memory" # postgres | sqlite | memory
|
|
66
|
-
# durable: PG-backed inbox/lease/nonce + recovery; ephemeral: one-pod
|
|
67
|
-
# runtime that intentionally loses kernel state on restart.
|
|
68
|
-
durability_tier: DurabilityTier = "durable"
|
|
69
|
-
dsn: str = ""
|
|
70
|
-
# server authority(hosted 必填)
|
|
71
|
-
jwks: Any | None = None
|
|
72
|
-
permit_issuer: str | None = None
|
|
73
|
-
nonce_store: Any | None = None
|
|
74
|
-
# 运行时
|
|
75
|
-
adapter_provider: Callable[[], RuntimeAdapter] | None = None
|
|
76
|
-
capabilities: Callable[[], RuntimeCapabilityMatrix] | None = None
|
|
77
|
-
start_request_defaults: dict[str, Any] = field(default_factory=dict)
|
|
78
|
-
# 契约 digest(hosted 必填 contract_digest)
|
|
79
|
-
contract_digest: str = ""
|
|
80
|
-
capability_digest: str = ""
|
|
81
|
-
bundle_digest: str = ""
|
|
82
|
-
# Session log 的 scope 必须与普通 SessionService、canonical event log
|
|
83
|
-
# 完全一致;否则 worker 可启动却会在首条 command 后看不到 session。
|
|
84
|
-
session_namespace: str = "default"
|
|
85
|
-
tenant_id: str = "default"
|
|
86
|
-
workspace_id: str = "default"
|
|
87
|
-
# 测试注入的 fake PG provider:提供时不再从 dsn 建真实连接,
|
|
88
|
-
# 但 hosted 模式的 dsn 必填校验仍然生效。
|
|
89
|
-
store: AgentKernelStore | None = None
|
|
90
|
-
session_events: Any | None = None
|
|
91
|
-
session_service: Any | None = None
|
|
92
|
-
# Runtime App composition root supplies these so recovery can attach via
|
|
93
|
-
# the same RuntimeAdapter registry rather than creating an unrelated path.
|
|
94
|
-
runtime_executor: Any | None = None
|
|
95
|
-
launch_context: Any | None = None
|
|
96
|
-
pool: Any | None = None
|
|
97
|
-
owns_pool: bool = False
|
|
98
|
-
# 生命周期参数
|
|
99
|
-
queue_limit: int = 100
|
|
100
|
-
lease_ttl_seconds: float = 60.0
|
|
101
|
-
poll_interval: float = 0.25
|
|
102
|
-
activation_id: str | None = None
|
|
103
|
-
runtime_type: str = "ksadk-agent-kernel"
|
|
104
|
-
clock: Callable[[], datetime] = now_utc
|
|
105
|
-
# 容错粒度:连续多少个不同 session 恢复失败才认为全局性故障(进程级
|
|
106
|
-
# degraded);store 连续多少个 poll 周期不可达才整体降级。
|
|
107
|
-
quarantine_degrade_threshold: int = 5
|
|
108
|
-
store_failure_degrade_threshold: int = 10
|
|
56
|
+
def _transient_backend_error(exc: BaseException) -> bool:
|
|
57
|
+
# Statement/lock deadlines and aborted transactions are recoverable without
|
|
58
|
+
# treating syntax, integrity or canonical conformance errors as outages.
|
|
59
|
+
return is_transient_session_backend_failure(exc)
|
|
60
|
+
|
|
61
|
+
|
|
109
62
|
|
|
110
63
|
|
|
111
64
|
class LeaseHeartbeat:
|
|
@@ -183,6 +136,121 @@ class LeaseHeartbeat:
|
|
|
183
136
|
self._last_tokens.pop(session_id, None)
|
|
184
137
|
|
|
185
138
|
|
|
139
|
+
@dataclass
|
|
140
|
+
class AgentKernelReadiness:
|
|
141
|
+
"""truthful readiness probe:每个维度都是真实查询,不是配置回显。"""
|
|
142
|
+
|
|
143
|
+
runtime: "AgentKernelRuntime"
|
|
144
|
+
|
|
145
|
+
async def check(self) -> dict[str, Any]:
|
|
146
|
+
config = self.runtime.config
|
|
147
|
+
store_ok = False
|
|
148
|
+
sessions = list(self.runtime.heartbeat_sessions())
|
|
149
|
+
read_leases = getattr(self.runtime.kernel_store, "read_runtime_leases", None)
|
|
150
|
+
leases = {}
|
|
151
|
+
try:
|
|
152
|
+
# 真实 store 查询(PG driver 即真实 SQL round-trip)。
|
|
153
|
+
if callable(read_leases):
|
|
154
|
+
leases = await read_leases(config.agent_instance_id, sessions)
|
|
155
|
+
else:
|
|
156
|
+
await self.runtime.kernel_store.list_messages(config.agent_instance_id)
|
|
157
|
+
store_ok = True
|
|
158
|
+
except Exception:
|
|
159
|
+
store_ok = False
|
|
160
|
+
|
|
161
|
+
lease_healthy = True
|
|
162
|
+
activation_id: str | None = None
|
|
163
|
+
for session_id in sessions:
|
|
164
|
+
try:
|
|
165
|
+
lease = (leases.get(session_id) if callable(read_leases)
|
|
166
|
+
else await self.runtime.kernel_store.current_lease(
|
|
167
|
+
config.agent_instance_id, session_id))
|
|
168
|
+
except Exception:
|
|
169
|
+
lease = None
|
|
170
|
+
if lease is None:
|
|
171
|
+
lease_healthy = False
|
|
172
|
+
continue
|
|
173
|
+
if not self.runtime.lease_heartbeat.owns_lease(session_id, lease):
|
|
174
|
+
# lease 存在但已被其它 activation 接管:对本 runtime 而言
|
|
175
|
+
# 等价于丢失,必须如实上报 not-ready。
|
|
176
|
+
lease_healthy = False
|
|
177
|
+
continue
|
|
178
|
+
activation_id = activation_id or lease.activation_id
|
|
179
|
+
expires = getattr(lease, "lease_expires_at", "")
|
|
180
|
+
try:
|
|
181
|
+
from datetime import datetime
|
|
182
|
+
|
|
183
|
+
expires_at = datetime.fromisoformat(str(expires).replace("Z", "+00:00"))
|
|
184
|
+
if expires_at <= datetime.now(expires_at.tzinfo):
|
|
185
|
+
lease_healthy = False
|
|
186
|
+
except ValueError:
|
|
187
|
+
lease_healthy = False
|
|
188
|
+
|
|
189
|
+
worker_running = self.runtime.worker_running
|
|
190
|
+
degraded = self.runtime.degraded
|
|
191
|
+
quarantined = self.runtime.quarantined_sessions()
|
|
192
|
+
capability = self.runtime.kernel.capabilities()
|
|
193
|
+
capability_matrix = runtime_capability_matrix_wire_value(capability)
|
|
194
|
+
computed_capability_digest = runtime_capability_admission_digest(
|
|
195
|
+
capability, config.capability_digest
|
|
196
|
+
)
|
|
197
|
+
# The control plane compares all three digests before declaring an
|
|
198
|
+
# AgentInstance ready. Reporting ready with only a contract digest
|
|
199
|
+
# would conceal a missing bundle/capability projection and make the
|
|
200
|
+
# runtime's health endpoint more optimistic than Server readiness.
|
|
201
|
+
digests_match = all(
|
|
202
|
+
(
|
|
203
|
+
config.contract_digest == AGENT_KERNEL_V1_AGGREGATE_DIGEST,
|
|
204
|
+
config.capability_digest == computed_capability_digest,
|
|
205
|
+
config.bundle_digest,
|
|
206
|
+
)
|
|
207
|
+
)
|
|
208
|
+
ready = store_ok and worker_running and lease_healthy and digests_match and not degraded
|
|
209
|
+
health = {
|
|
210
|
+
"ready": ready,
|
|
211
|
+
"store_ok": store_ok,
|
|
212
|
+
"worker_running": worker_running,
|
|
213
|
+
"degraded": degraded,
|
|
214
|
+
# additive:被隔离(恢复失败)的 session 数量;隔离本身不影响
|
|
215
|
+
# ready,其余 session 照常服务。
|
|
216
|
+
"quarantined_sessions": len(quarantined),
|
|
217
|
+
"recovering_sessions": len(self.runtime._session_retry_after),
|
|
218
|
+
"lease_healthy": lease_healthy,
|
|
219
|
+
"activation_id": activation_id,
|
|
220
|
+
# Contract support is packaged with this KsADK image; never echo
|
|
221
|
+
# an unverified control-plane environment value as evidence.
|
|
222
|
+
"contract_digest": AGENT_KERNEL_V1_AGGREGATE_DIGEST,
|
|
223
|
+
# Derive the admission proof from the actual Adapter matrix and the
|
|
224
|
+
# selected policy rather than echoing the deployment value blindly.
|
|
225
|
+
"capability_digest": computed_capability_digest,
|
|
226
|
+
# Runtime/Operator/Server readiness chain must carry the actual
|
|
227
|
+
# typed capability facts, not merely a digest supplied at deploy
|
|
228
|
+
# time. Server admission uses these to reject unsupported control
|
|
229
|
+
# operations before they enter the durable inbox.
|
|
230
|
+
"capabilities": capability_matrix,
|
|
231
|
+
"bundle_digest": config.bundle_digest,
|
|
232
|
+
"durability_tier": config.durability_tier,
|
|
233
|
+
# Identity is derived from the KsADK source Python imported, not
|
|
234
|
+
# ``importlib.metadata`` for the base image distribution.
|
|
235
|
+
"runtime_identity": runtime_identity(),
|
|
236
|
+
}
|
|
237
|
+
# 诊断字段(additive,runtime 内部端点非 wire 冻结合同):
|
|
238
|
+
# degraded 时必须能从 health 直接回答 "为什么降级、何时降级",
|
|
239
|
+
# 出问题的 session 明细同样可见,运维不必再对着布尔值猜。
|
|
240
|
+
teams_descriptor = getattr(self.runtime, "teams_host_descriptor", None)
|
|
241
|
+
if teams_descriptor is not None:
|
|
242
|
+
health["teams_host"] = await teams_descriptor()
|
|
243
|
+
if quarantined:
|
|
244
|
+
health["quarantined_session_ids"] = sorted(quarantined)
|
|
245
|
+
if self.runtime._session_retry_after:
|
|
246
|
+
health["recovering_session_ids"] = sorted(self.runtime._session_retry_after)
|
|
247
|
+
if degraded:
|
|
248
|
+
health["degradation_reason"] = self.runtime._degradation_reason
|
|
249
|
+
health["degraded_at"] = self.runtime._degraded_at
|
|
250
|
+
health["degradation_last_error"] = self.runtime._degraded_last_error
|
|
251
|
+
return health
|
|
252
|
+
|
|
253
|
+
|
|
186
254
|
@dataclass
|
|
187
255
|
class AgentKernelRuntime:
|
|
188
256
|
"""生产 kernel runtime:start() 启动后台 worker/lease loop,close() 全停。"""
|
|
@@ -204,14 +272,16 @@ class AgentKernelRuntime:
|
|
|
204
272
|
self._session_tasks: dict[str, asyncio.Task[bool]] = {}
|
|
205
273
|
self._worker_running = False
|
|
206
274
|
self._last_scheduler_poll = 0.0
|
|
207
|
-
self._session_capacity_exhausted = False
|
|
208
275
|
self._heartbeat_sessions: set[str] = set()
|
|
209
276
|
self._last_renewed: dict[str, float] = {}
|
|
210
277
|
self._degraded = False
|
|
211
278
|
# P0-1 粒度修正:单个 session 恢复失败不再拖垮整个 runtime。
|
|
212
279
|
self._quarantined: set[str] = set()
|
|
280
|
+
self._session_retry_after: dict[str, float] = {}
|
|
281
|
+
self._session_retry_attempts: dict[str, int] = {}
|
|
213
282
|
self._recovery_failed_sessions: set[str] = set()
|
|
214
283
|
self._store_failures = 0
|
|
284
|
+
self._last_scheduled_session = ""
|
|
215
285
|
# 诊断状态:degraded 必须能回答 "为什么、什么时候、哪些 session",
|
|
216
286
|
# 让 kubectl logs 与 health 端点一眼可见(此前只有 degraded 布尔值)。
|
|
217
287
|
self._degradation_reason: str | None = None
|
|
@@ -249,7 +319,6 @@ class AgentKernelRuntime:
|
|
|
249
319
|
return (
|
|
250
320
|
self._worker_running
|
|
251
321
|
and not self._degraded
|
|
252
|
-
and not self._session_capacity_exhausted
|
|
253
322
|
and time.monotonic() - self._last_scheduler_poll
|
|
254
323
|
<= max(10.0, self.config.poll_interval * 20)
|
|
255
324
|
)
|
|
@@ -300,6 +369,9 @@ class AgentKernelRuntime:
|
|
|
300
369
|
self._tasks.clear()
|
|
301
370
|
self._session_tasks.clear()
|
|
302
371
|
self._worker_running = False
|
|
372
|
+
await self.worker.close()
|
|
373
|
+
if self.worker._mcp_authorization is not None:
|
|
374
|
+
await self.worker._mcp_authorization.client.close()
|
|
303
375
|
# best-effort 释放持有的 activation(不阻塞关闭)。
|
|
304
376
|
for session_id in list(self._heartbeat_sessions | self._quarantined):
|
|
305
377
|
try:
|
|
@@ -311,13 +383,18 @@ class AgentKernelRuntime:
|
|
|
311
383
|
lease.activation_id, expected_fence=lease.fencing_token
|
|
312
384
|
)
|
|
313
385
|
except Exception:
|
|
314
|
-
|
|
386
|
+
logger.exception(
|
|
387
|
+
"Failed to release Kernel activation on shutdown: session_id=%s",
|
|
388
|
+
session_id,
|
|
389
|
+
)
|
|
315
390
|
self.lease_heartbeat.forget(session_id)
|
|
316
391
|
self._heartbeat_sessions.clear()
|
|
317
392
|
self._last_renewed.clear()
|
|
318
393
|
if self._owns_pool and self._pool is not None and hasattr(self._pool, "close"):
|
|
394
|
+
from ksadk.kernel.session_storage import close_owned_kernel_pool
|
|
395
|
+
pool, self._pool = self._pool, None
|
|
319
396
|
try:
|
|
320
|
-
await self.
|
|
397
|
+
await close_owned_kernel_pool(self.config.session_service, pool)
|
|
321
398
|
except Exception:
|
|
322
399
|
pass
|
|
323
400
|
if self._owns_store and hasattr(self.kernel_store, "close"):
|
|
@@ -325,6 +402,8 @@ class AgentKernelRuntime:
|
|
|
325
402
|
await self.kernel_store.close() # type: ignore[attr-defined]
|
|
326
403
|
except Exception:
|
|
327
404
|
pass
|
|
405
|
+
from ksadk.runtime.session_storage import close_preflight_adapter
|
|
406
|
+
await close_preflight_adapter(self.config.preflight_adapter)
|
|
328
407
|
|
|
329
408
|
# ------------------------------------------------------------- run loop
|
|
330
409
|
|
|
@@ -348,6 +427,8 @@ class AgentKernelRuntime:
|
|
|
348
427
|
except Exception as exc:
|
|
349
428
|
task_failed = True
|
|
350
429
|
self._store_failures += 1
|
|
430
|
+
if _transient_backend_error(exc):
|
|
431
|
+
await self._quarantine_session(session_id, exc, context="session poll")
|
|
351
432
|
logger.exception(
|
|
352
433
|
"agent kernel session poll failed: "
|
|
353
434
|
"agent_instance_id=%s session_id=%s "
|
|
@@ -364,18 +445,29 @@ class AgentKernelRuntime:
|
|
|
364
445
|
self._mark_degraded("store_unreachable", exc)
|
|
365
446
|
return
|
|
366
447
|
sessions = await self._pending_sessions()
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
448
|
+
had_capacity = len(self._session_tasks) < MAX_CONCURRENT_KERNEL_SESSIONS
|
|
449
|
+
blocked = False
|
|
450
|
+
ordered = sorted(sessions)
|
|
451
|
+
# WAITING runs stay eligible between polls. Rotate the first
|
|
452
|
+
# slot so a full batch cannot permanently starve a new id.
|
|
453
|
+
start = bisect_right(ordered, self._last_scheduled_session)
|
|
454
|
+
for session_id in ordered[start:] + ordered[:start]:
|
|
370
455
|
if session_id in self._quarantined or session_id in self._session_tasks:
|
|
371
456
|
continue
|
|
457
|
+
if time.monotonic() < self._session_retry_after.get(session_id, 0):
|
|
458
|
+
continue
|
|
372
459
|
if len(self._session_tasks) >= MAX_CONCURRENT_KERNEL_SESSIONS:
|
|
373
|
-
|
|
460
|
+
blocked = True
|
|
374
461
|
break
|
|
375
462
|
self._session_tasks[session_id] = asyncio.create_task(
|
|
376
463
|
self._run_session_once(session_id),
|
|
377
464
|
name=f"kernel-session:{session_id}",
|
|
378
465
|
)
|
|
466
|
+
self._last_scheduled_session = session_id
|
|
467
|
+
# A full batch that keeps freeing slots is healthy. Retain
|
|
468
|
+
# the existing liveness deadline for genuinely stuck tasks.
|
|
469
|
+
if had_capacity or not blocked:
|
|
470
|
+
self._last_scheduler_poll = time.monotonic()
|
|
379
471
|
if not task_failed:
|
|
380
472
|
self._store_failures = 0
|
|
381
473
|
except asyncio.CancelledError:
|
|
@@ -392,6 +484,16 @@ class AgentKernelRuntime:
|
|
|
392
484
|
self._store_failures >= self.config.store_failure_degrade_threshold
|
|
393
485
|
and not await self._store_reachable()
|
|
394
486
|
):
|
|
487
|
+
if _transient_backend_error(exc):
|
|
488
|
+
# A background read outage must not permanently stop
|
|
489
|
+
# this runtime. Readiness remains truthful/unavailable;
|
|
490
|
+
# the same durable Inbox is polled after recovery.
|
|
491
|
+
await asyncio.sleep(min(
|
|
492
|
+
5.0, max(0.2, self.config.poll_interval * 4)
|
|
493
|
+
* 2 ** min(5, self._store_failures
|
|
494
|
+
- self.config.store_failure_degrade_threshold),
|
|
495
|
+
))
|
|
496
|
+
continue
|
|
395
497
|
# store 持续不可达是全局性故障:宁降级不静默。
|
|
396
498
|
self._mark_degraded("store_unreachable", exc)
|
|
397
499
|
return
|
|
@@ -409,6 +511,36 @@ class AgentKernelRuntime:
|
|
|
409
511
|
return False
|
|
410
512
|
self._heartbeat_sessions.add(session_id)
|
|
411
513
|
self._last_renewed[session_id] = time.monotonic()
|
|
514
|
+
if session_id in self._session_retry_after:
|
|
515
|
+
# A provider start/commit may have succeeded before a transport
|
|
516
|
+
# failure. Settle the existing run under the current fence rather
|
|
517
|
+
# than blindly starting it again. With no run (pre-start read
|
|
518
|
+
# failure), the same claimed command can safely be tried again.
|
|
519
|
+
try:
|
|
520
|
+
active = await self.kernel_store.find_active_run(self.config.agent_instance_id, session_id)
|
|
521
|
+
execution = self.worker.execution_for(active.run_id) if active is not None else None
|
|
522
|
+
live_owner = (
|
|
523
|
+
execution is not None and execution.stream_task is not None
|
|
524
|
+
and not execution.stream_task.done() and execution.stream_guard is not None
|
|
525
|
+
and execution.stream_guard.activation_id == lease.activation_id
|
|
526
|
+
and execution.stream_guard.fencing_token == lease.fencing_token
|
|
527
|
+
)
|
|
528
|
+
if not live_owner:
|
|
529
|
+
await self.recovery.settle_interrupted(
|
|
530
|
+
self.config.agent_instance_id, lease, session_id=session_id,
|
|
531
|
+
reason="runtime_backend_timeout",
|
|
532
|
+
)
|
|
533
|
+
except StaleFenceError:
|
|
534
|
+
self._session_retry_after.pop(session_id, None)
|
|
535
|
+
self._heartbeat_sessions.discard(session_id)
|
|
536
|
+
self._last_renewed.pop(session_id, None)
|
|
537
|
+
self.lease_heartbeat.forget(session_id)
|
|
538
|
+
return False
|
|
539
|
+
except Exception as error:
|
|
540
|
+
await self._quarantine_session(session_id, error, context="backend recovery")
|
|
541
|
+
return False
|
|
542
|
+
self._session_retry_after.pop(session_id, None)
|
|
543
|
+
took_over = False
|
|
412
544
|
if took_over:
|
|
413
545
|
failure = await self._recover_safely(lease, session_id)
|
|
414
546
|
if failure is not None:
|
|
@@ -417,6 +549,10 @@ class AgentKernelRuntime:
|
|
|
417
549
|
active = await self.kernel_store.find_active_run(
|
|
418
550
|
self.config.agent_instance_id, session_id
|
|
419
551
|
)
|
|
552
|
+
if active is None:
|
|
553
|
+
await self.worker.close_retired_session_attachments(session_id)
|
|
554
|
+
if await self._release_missing_session(session_id, lease):
|
|
555
|
+
return False
|
|
420
556
|
if active is not None and self.worker.take_stream_failure(
|
|
421
557
|
active.run_id, lease
|
|
422
558
|
) is not None:
|
|
@@ -451,6 +587,8 @@ class AgentKernelRuntime:
|
|
|
451
587
|
await self._quarantine_session(
|
|
452
588
|
session_id, failure, context="command execution"
|
|
453
589
|
)
|
|
590
|
+
if result.outcome in {"claimed", "completed"}:
|
|
591
|
+
self._session_retry_attempts.pop(session_id, None)
|
|
454
592
|
return result.outcome in {"claimed", "completed"}
|
|
455
593
|
|
|
456
594
|
async def _heartbeat_loop(self) -> None:
|
|
@@ -463,6 +601,22 @@ class AgentKernelRuntime:
|
|
|
463
601
|
if self._degraded:
|
|
464
602
|
return
|
|
465
603
|
|
|
604
|
+
async def _release_missing_session(self, session_id: str, lease) -> bool:
|
|
605
|
+
missing = getattr(self.kernel_store, "is_session_missing", None)
|
|
606
|
+
if missing is None or not await missing(session_id):
|
|
607
|
+
return False
|
|
608
|
+
try:
|
|
609
|
+
await self.kernel_store.release_activation(lease.activation_id, expected_fence=lease.fencing_token)
|
|
610
|
+
except StaleFenceError:
|
|
611
|
+
pass
|
|
612
|
+
if self.lease_heartbeat._last_tokens.get(session_id) == lease.fencing_token:
|
|
613
|
+
self.lease_heartbeat.forget(session_id)
|
|
614
|
+
self._heartbeat_sessions.discard(session_id)
|
|
615
|
+
self._last_renewed.pop(session_id, None)
|
|
616
|
+
self._session_retry_after.pop(session_id, None)
|
|
617
|
+
self._session_retry_attempts.pop(session_id, None)
|
|
618
|
+
return True
|
|
619
|
+
|
|
466
620
|
async def _renew_leased_sessions(self) -> None:
|
|
467
621
|
"""P0:已持有 lease 的 session 在固定间隔上持续续约。
|
|
468
622
|
|
|
@@ -475,7 +629,31 @@ class AgentKernelRuntime:
|
|
|
475
629
|
|
|
476
630
|
interval = max(self.config.lease_ttl_seconds / 3.0, self.config.poll_interval)
|
|
477
631
|
now = time.monotonic()
|
|
478
|
-
for
|
|
632
|
+
due = [s for s in sorted(self._heartbeat_sessions)
|
|
633
|
+
if s not in self._quarantined
|
|
634
|
+
and now - self._last_renewed.get(s, 0.0) >= interval]
|
|
635
|
+
renew = getattr(self.kernel_store, "renew_owned_activations", None)
|
|
636
|
+
if callable(renew):
|
|
637
|
+
owned = {s: (self.lease_heartbeat.activation_id_for_session(s),
|
|
638
|
+
self.lease_heartbeat._last_tokens[s])
|
|
639
|
+
for s in due if s in self.lease_heartbeat._last_tokens}
|
|
640
|
+
try:
|
|
641
|
+
renewed = await renew(
|
|
642
|
+
self.config.agent_instance_id, owned,
|
|
643
|
+
lease_ttl_seconds=self.config.lease_ttl_seconds,
|
|
644
|
+
)
|
|
645
|
+
except asyncio.CancelledError:
|
|
646
|
+
raise
|
|
647
|
+
except Exception as exc:
|
|
648
|
+
# Retry the same lease renewal on the next heartbeat. Never
|
|
649
|
+
# turn a shared outage into hundreds of sequential DB calls.
|
|
650
|
+
logger.warning("Kernel batch lease renewal failed (%s); retrying next heartbeat",
|
|
651
|
+
type(exc).__name__)
|
|
652
|
+
return
|
|
653
|
+
for session_id in renewed:
|
|
654
|
+
self._last_renewed[session_id] = now
|
|
655
|
+
due = [s for s in due if s not in renewed]
|
|
656
|
+
for session_id in due:
|
|
479
657
|
if session_id in self._quarantined:
|
|
480
658
|
continue
|
|
481
659
|
if now - self._last_renewed.get(session_id, 0.0) < interval:
|
|
@@ -483,6 +661,8 @@ class AgentKernelRuntime:
|
|
|
483
661
|
self._last_renewed[session_id] = now
|
|
484
662
|
try:
|
|
485
663
|
lease, took_over = await self.lease_heartbeat.ensure_lease(session_id)
|
|
664
|
+
if lease is not None and await self._release_missing_session(session_id, lease):
|
|
665
|
+
continue
|
|
486
666
|
except asyncio.CancelledError:
|
|
487
667
|
raise
|
|
488
668
|
except Exception:
|
|
@@ -564,7 +744,11 @@ class AgentKernelRuntime:
|
|
|
564
744
|
"""store 是否仍可用:用于区分 session 级故障与全局连接故障。"""
|
|
565
745
|
|
|
566
746
|
try:
|
|
567
|
-
|
|
747
|
+
probe = getattr(self.kernel_store, "read_runtime_leases", None)
|
|
748
|
+
if callable(probe):
|
|
749
|
+
await probe(self.config.agent_instance_id, [])
|
|
750
|
+
else:
|
|
751
|
+
await self.kernel_store.list_messages(self.config.agent_instance_id)
|
|
568
752
|
except Exception:
|
|
569
753
|
return False
|
|
570
754
|
return True
|
|
@@ -585,10 +769,43 @@ class AgentKernelRuntime:
|
|
|
585
769
|
才升级为进程级 degraded。
|
|
586
770
|
"""
|
|
587
771
|
|
|
772
|
+
if _transient_backend_error(exc):
|
|
773
|
+
# Database deadlines are transient transport failures, not proof
|
|
774
|
+
# of corrupt history. Keep the lease heartbeat and retry with
|
|
775
|
+
# capped exponential backoff; do not permanently quarantine.
|
|
776
|
+
attempt = self._session_retry_attempts.get(session_id, 0) + 1
|
|
777
|
+
self._session_retry_attempts[session_id] = attempt
|
|
778
|
+
delay = min(30.0, 0.5 * 2 ** min(attempt - 1, 6))
|
|
779
|
+
self._session_retry_after[session_id] = time.monotonic() + delay
|
|
780
|
+
logger.warning("agent kernel session %s retrying %s after %.1fs: %s: %s",
|
|
781
|
+
session_id, context, delay, type(exc).__name__, exc)
|
|
782
|
+
return True
|
|
783
|
+
self._session_retry_after.pop(session_id, None)
|
|
588
784
|
if not await self._store_reachable():
|
|
589
785
|
# store 本身不可达:这不是单个 session 的问题。
|
|
590
786
|
self._mark_degraded("store_unreachable_during_recovery", exc)
|
|
591
787
|
return False
|
|
788
|
+
# Deletion can race a recovery/stream that already acquired its lease.
|
|
789
|
+
# Built-in stores retire missing sessions on their next fenced claim.
|
|
790
|
+
# An external event log can report absence without being atomic with
|
|
791
|
+
# the Kernel. Isolate that session locally, preserving its durable work.
|
|
792
|
+
missing = getattr(self.kernel_store, "is_session_missing", None)
|
|
793
|
+
event_missing = getattr(self.session_events, "is_session_missing", None)
|
|
794
|
+
try:
|
|
795
|
+
if missing is not None and await missing(session_id):
|
|
796
|
+
return True
|
|
797
|
+
if event_missing is not None and await event_missing(session_id):
|
|
798
|
+
self._quarantined.add(session_id)
|
|
799
|
+
self._heartbeat_sessions.discard(session_id)
|
|
800
|
+
self._last_renewed.pop(session_id, None)
|
|
801
|
+
self.lease_heartbeat.forget(session_id)
|
|
802
|
+
await self.worker.close_retired_session_attachments(session_id, missing=True)
|
|
803
|
+
logger.warning("Kernel session %s is missing from its external session store", session_id)
|
|
804
|
+
return True
|
|
805
|
+
except Exception as lookup_error:
|
|
806
|
+
if _transient_backend_error(lookup_error):
|
|
807
|
+
return await self._quarantine_session(session_id, lookup_error, context="session lookup")
|
|
808
|
+
logger.exception("Could not verify existence of kernel session %s", session_id)
|
|
592
809
|
self._quarantined.add(session_id)
|
|
593
810
|
self._recovery_failed_sessions.add(session_id)
|
|
594
811
|
self._heartbeat_sessions.discard(session_id)
|
|
@@ -604,6 +821,23 @@ class AgentKernelRuntime:
|
|
|
604
821
|
exc,
|
|
605
822
|
)
|
|
606
823
|
if len(self._recovery_failed_sessions) >= self.config.quarantine_degrade_threshold:
|
|
824
|
+
# A session quarantined for another reason may since have been
|
|
825
|
+
# deleted. Historical failures are not evidence of a current outage.
|
|
826
|
+
if missing is not None:
|
|
827
|
+
for previous in self._recovery_failed_sessions.copy() - {session_id}:
|
|
828
|
+
try:
|
|
829
|
+
deleted = await missing(previous)
|
|
830
|
+
except Exception as lookup_error:
|
|
831
|
+
logger.warning("Could not recheck quarantined session %s: %s", previous,
|
|
832
|
+
type(lookup_error).__name__)
|
|
833
|
+
if _transient_backend_error(lookup_error):
|
|
834
|
+
return True
|
|
835
|
+
continue
|
|
836
|
+
if deleted:
|
|
837
|
+
self._quarantined.discard(previous)
|
|
838
|
+
self._recovery_failed_sessions.discard(previous)
|
|
839
|
+
if len(self._recovery_failed_sessions) < self.config.quarantine_degrade_threshold:
|
|
840
|
+
return True
|
|
607
841
|
self._mark_degraded(
|
|
608
842
|
"recovery_failures_spread_to_%d_sessions" % len(self._recovery_failed_sessions),
|
|
609
843
|
exc,
|
|
@@ -612,6 +846,12 @@ class AgentKernelRuntime:
|
|
|
612
846
|
return True
|
|
613
847
|
|
|
614
848
|
async def _pending_sessions(self) -> set[str]:
|
|
849
|
+
read_pending = getattr(self.kernel_store, "pending_session_ids", None)
|
|
850
|
+
if callable(read_pending):
|
|
851
|
+
sessions = await read_pending(self.config.agent_instance_id)
|
|
852
|
+
oauth_sessions = (await self.worker._mcp_authorization.pending_session_ids(self.config.agent_instance_id)
|
|
853
|
+
if self.worker._mcp_authorization is not None else set())
|
|
854
|
+
return set(sessions) | oauth_sessions | self.worker.active_session_ids() | set(self._session_retry_after)
|
|
615
855
|
messages = await self.kernel_store.list_messages(self.config.agent_instance_id)
|
|
616
856
|
inbox_sessions = {
|
|
617
857
|
message.session_id
|
|
@@ -639,7 +879,17 @@ class AgentKernelRuntime:
|
|
|
639
879
|
# releases the retained leases; an ungraceful stop lets their TTL
|
|
640
880
|
# expire for recovery by a new activation.
|
|
641
881
|
active_sessions = self.worker.active_session_ids()
|
|
642
|
-
|
|
882
|
+
# SQLite's fallback scan also needs the extension's final acknowledgement
|
|
883
|
+
# after a Run becomes terminal. Otherwise the OAuth card remains waiting.
|
|
884
|
+
oauth_sessions = (
|
|
885
|
+
await self.worker._mcp_authorization.pending_session_ids(self.config.agent_instance_id)
|
|
886
|
+
if self.worker._mcp_authorization is not None
|
|
887
|
+
else set()
|
|
888
|
+
)
|
|
889
|
+
return (
|
|
890
|
+
inbox_sessions | open_run_sessions | active_sessions | oauth_sessions
|
|
891
|
+
| set(self._session_retry_after)
|
|
892
|
+
)
|
|
643
893
|
|
|
644
894
|
|
|
645
895
|
# ---------------------------------------------------------------------------
|
|
@@ -759,12 +1009,15 @@ def build_agent_kernel_runtime(
|
|
|
759
1009
|
events = PostgresFencedSessionEventStore(kernel_store) # type: ignore[arg-type]
|
|
760
1010
|
elif config.driver == "sqlite":
|
|
761
1011
|
from ksadk.kernel.sqlite_store import SQLiteAgentKernelStore
|
|
762
|
-
from ksadk.sessions.
|
|
1012
|
+
from ksadk.sessions.local_service import LocalSessionService
|
|
763
1013
|
|
|
764
1014
|
if not config.dsn:
|
|
765
1015
|
raise RuntimeError("sqlite agent kernel runtime requires a database path")
|
|
766
1016
|
if session_service is None:
|
|
767
|
-
session_service =
|
|
1017
|
+
session_service = LocalSessionService(db_path=config.dsn)
|
|
1018
|
+
# Legacy Studio/control hosts may use another Session backend.
|
|
1019
|
+
# Preserve that composition; SQLiteInteractionStoreMixin checks
|
|
1020
|
+
# same-database atomicity before publishing an Interaction/v1 fact.
|
|
768
1021
|
base_events = SessionServiceEventStore(session_service)
|
|
769
1022
|
kernel_store = SQLiteAgentKernelStore(config.dsn, base_events)
|
|
770
1023
|
events = base_events
|
|
@@ -832,6 +1085,9 @@ def build_agent_kernel_runtime(
|
|
|
832
1085
|
queue_limit=config.queue_limit,
|
|
833
1086
|
capabilities=capabilities,
|
|
834
1087
|
clock=config.clock,
|
|
1088
|
+
session_admission_error=lambda sid: (
|
|
1089
|
+
"session_quarantined" if sid in runtime.quarantined_sessions() else None
|
|
1090
|
+
),
|
|
835
1091
|
)
|
|
836
1092
|
worker = AgentKernelWorker(
|
|
837
1093
|
store,
|
|
@@ -856,7 +1112,10 @@ def build_agent_kernel_runtime(
|
|
|
856
1112
|
heartbeat = LeaseHeartbeat(
|
|
857
1113
|
store,
|
|
858
1114
|
agent_instance_id=config.agent_instance_id,
|
|
859
|
-
|
|
1115
|
+
# An unspecified owner belongs to this Runtime lifetime. Reusing a
|
|
1116
|
+
# deterministic owner after a crash can renew its old fence and skip
|
|
1117
|
+
# recovery even though this process has no attached execution.
|
|
1118
|
+
activation_id=config.activation_id or f"{config.agent_instance_id}:kernel-runtime:{uuid4().hex}",
|
|
860
1119
|
runtime_type=config.runtime_type,
|
|
861
1120
|
bundle_digest=config.bundle_digest,
|
|
862
1121
|
# The lease carries the verified admission policy; command admission
|
|
@@ -866,6 +1125,7 @@ def build_agent_kernel_runtime(
|
|
|
866
1125
|
),
|
|
867
1126
|
lease_ttl_seconds=config.lease_ttl_seconds,
|
|
868
1127
|
)
|
|
1128
|
+
config.session_service = session_service
|
|
869
1129
|
runtime = AgentKernelRuntime(
|
|
870
1130
|
config=config,
|
|
871
1131
|
kernel=kernel,
|
|
@@ -894,164 +1154,20 @@ async def bootstrap_agent_kernel_runtime_from_env(
|
|
|
894
1154
|
launch_context: Any | None = None,
|
|
895
1155
|
start_request_defaults: dict[str, Any] | None = None,
|
|
896
1156
|
session_service: Any | None = None,
|
|
1157
|
+
session_service_explicit: bool | None = None,
|
|
1158
|
+
storage_owner: Any | None = None,
|
|
897
1159
|
before_start: Any | None = None,
|
|
898
1160
|
) -> AgentKernelRuntime | None:
|
|
899
|
-
"""
|
|
900
|
-
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
904
|
-
|
|
905
|
-
|
|
906
|
-
|
|
907
|
-
_remote_jwks_source,
|
|
908
|
-
authority_mode,
|
|
909
|
-
set_agent_kernel,
|
|
1161
|
+
"""Assemble the configured runtime through the environment projection."""
|
|
1162
|
+
from ksadk.kernel.runtime_environment import bootstrap_runtime_from_env
|
|
1163
|
+
|
|
1164
|
+
return await bootstrap_runtime_from_env(
|
|
1165
|
+
adapter_provider=adapter_provider, runtime_executor=runtime_executor,
|
|
1166
|
+
launch_context=launch_context, start_request_defaults=start_request_defaults,
|
|
1167
|
+
session_service=session_service, session_service_explicit=session_service_explicit,
|
|
1168
|
+
storage_owner=storage_owner, before_start=before_start,
|
|
910
1169
|
)
|
|
911
1170
|
|
|
912
|
-
enabled = os.environ.get("AGENT_KERNEL_ENABLED", "").strip().lower() in {
|
|
913
|
-
"1",
|
|
914
|
-
"true",
|
|
915
|
-
"yes",
|
|
916
|
-
"on",
|
|
917
|
-
}
|
|
918
|
-
if not enabled:
|
|
919
|
-
return None
|
|
920
|
-
if get_agent_kernel_runtime() is not None:
|
|
921
|
-
return get_agent_kernel_runtime()
|
|
922
|
-
|
|
923
|
-
driver = os.environ.get("AGENT_KERNEL_STORE_DRIVER", "memory").strip().lower()
|
|
924
|
-
dsn = os.environ.get("AGENT_KERNEL_STORE_DSN", "").strip()
|
|
925
|
-
jwks_url = os.environ.get(ENV_JWKS_URL, "").strip()
|
|
926
|
-
session_namespace = os.environ.get("KSADK_SESSION_NAMESPACE", "default").strip() or "default"
|
|
927
|
-
tenant_id = (
|
|
928
|
-
os.environ.get("KSADK_TENANT_ID") or os.environ.get("AGENTENGINE_TENANT_ID") or "default"
|
|
929
|
-
).strip()
|
|
930
|
-
workspace_id = (
|
|
931
|
-
os.environ.get("KSADK_WORKSPACE_ID")
|
|
932
|
-
or os.environ.get("AGENTENGINE_WORKSPACE_ID")
|
|
933
|
-
or "default"
|
|
934
|
-
).strip()
|
|
935
|
-
mode: AuthorityMode = authority_mode() # type: ignore[assignment]
|
|
936
|
-
durability_tier: DurabilityTier = (
|
|
937
|
-
os.environ.get("AGENT_KERNEL_DURABILITY_TIER", "durable").strip().lower()
|
|
938
|
-
) # type: ignore[assignment]
|
|
939
|
-
injected_contract_digest = os.environ.get("AGENT_KERNEL_CONTRACT_DIGEST", "").strip()
|
|
940
|
-
if mode == "hosted" and injected_contract_digest != AGENT_KERNEL_V1_AGGREGATE_DIGEST:
|
|
941
|
-
raise RuntimeError(
|
|
942
|
-
"contract_digest_mismatch: hosted agent kernel runtime image "
|
|
943
|
-
"does not support the control-plane contract digest"
|
|
944
|
-
)
|
|
945
|
-
|
|
946
|
-
# Lazy framework adapters learn their native checkpoint capabilities during
|
|
947
|
-
# preflight. Snapshotting before it permanently disables cold recovery even
|
|
948
|
-
# when the deployment has configured durable native sessions.
|
|
949
|
-
capabilities = None
|
|
950
|
-
if adapter_provider is not None:
|
|
951
|
-
capability_adapter = adapter_provider()
|
|
952
|
-
await capability_adapter.preflight()
|
|
953
|
-
capabilities = capability_adapter.capabilities
|
|
954
|
-
|
|
955
|
-
pool = None
|
|
956
|
-
owns_pool = False
|
|
957
|
-
if driver == "postgres":
|
|
958
|
-
from ksadk.kernel.postgres_store import (
|
|
959
|
-
PostgresAgentKernelStore,
|
|
960
|
-
PostgresFencedSessionEventStore,
|
|
961
|
-
PostgresKernelEventLog,
|
|
962
|
-
PostgresNonceStore,
|
|
963
|
-
)
|
|
964
|
-
from ksadk.sessions.postgres_service import PostgresSessionService
|
|
965
|
-
|
|
966
|
-
if not dsn:
|
|
967
|
-
raise RuntimeError("postgres kernel store requires AGENT_KERNEL_STORE_DSN")
|
|
968
|
-
session_service = PostgresSessionService(
|
|
969
|
-
dsn=dsn,
|
|
970
|
-
namespace=session_namespace,
|
|
971
|
-
tenant_id=tenant_id,
|
|
972
|
-
workspace_id=workspace_id,
|
|
973
|
-
)
|
|
974
|
-
await session_service._ensure_pool()
|
|
975
|
-
pool = session_service._pool
|
|
976
|
-
event_log = PostgresKernelEventLog(
|
|
977
|
-
pool,
|
|
978
|
-
namespace=session_service.namespace,
|
|
979
|
-
tenant_id=session_service.tenant_id,
|
|
980
|
-
workspace_id=session_service.workspace_id,
|
|
981
|
-
)
|
|
982
|
-
store: AgentKernelStore = PostgresAgentKernelStore(
|
|
983
|
-
pool, event_log, tenant_id=session_service.tenant_id, owns_pool=True
|
|
984
|
-
)
|
|
985
|
-
await store.ensure_schema()
|
|
986
|
-
session_events: Any = PostgresFencedSessionEventStore(store)
|
|
987
|
-
nonce_store: Any = PostgresNonceStore(pool)
|
|
988
|
-
owns_pool = True
|
|
989
|
-
else:
|
|
990
|
-
from ksadk.kernel.memory_store import InMemoryAgentKernelStore
|
|
991
|
-
from ksadk.sessions.in_memory import InMemorySessionService
|
|
992
|
-
|
|
993
|
-
# The HTTP Session routes and the Kernel worker must project through
|
|
994
|
-
# one physical Session log. The Runtime App passes its owned service
|
|
995
|
-
# here so a foreground kernel stream remains replayable through
|
|
996
|
-
# ListSessionEvents/ListSessionMessages after refresh. Standalone
|
|
997
|
-
# bootstrap callers retain the historical in-memory default.
|
|
998
|
-
if session_service is None:
|
|
999
|
-
session_service = InMemorySessionService()
|
|
1000
|
-
session_events = SessionServiceEventStore(session_service)
|
|
1001
|
-
store = InMemoryAgentKernelStore(session_events)
|
|
1002
|
-
# Explicit ephemeral hosted mode still needs replay protection while
|
|
1003
|
-
# this process lives. It does not promise restart durability.
|
|
1004
|
-
nonce_store = InMemoryNonceStore()
|
|
1005
|
-
|
|
1006
|
-
agent_instance_id = os.environ.get("AGENT_INSTANCE_ID", "").strip()
|
|
1007
|
-
if not agent_instance_id and mode != "hosted":
|
|
1008
|
-
agent_instance_id = "local-agent"
|
|
1009
|
-
pod_uid = os.environ.get("POD_UID", "").strip()
|
|
1010
|
-
config = AgentKernelRuntimeConfig(
|
|
1011
|
-
agent_instance_id=agent_instance_id,
|
|
1012
|
-
authority_mode=mode,
|
|
1013
|
-
driver=driver,
|
|
1014
|
-
durability_tier=durability_tier,
|
|
1015
|
-
dsn=dsn,
|
|
1016
|
-
jwks=_remote_jwks_source(jwks_url) if mode == "hosted" else None,
|
|
1017
|
-
permit_issuer=os.environ.get("AGENT_CONTROL_PERMIT_ISSUER", ""),
|
|
1018
|
-
nonce_store=nonce_store,
|
|
1019
|
-
adapter_provider=adapter_provider,
|
|
1020
|
-
capabilities=capabilities,
|
|
1021
|
-
start_request_defaults=dict(start_request_defaults or {}),
|
|
1022
|
-
contract_digest=(
|
|
1023
|
-
AGENT_KERNEL_V1_AGGREGATE_DIGEST if mode == "hosted" else injected_contract_digest
|
|
1024
|
-
),
|
|
1025
|
-
capability_digest=os.environ.get("AGENT_KERNEL_CAPABILITY_DIGEST", ""),
|
|
1026
|
-
bundle_digest=os.environ.get("AGENT_BUNDLE_DIGEST", ""),
|
|
1027
|
-
session_namespace=session_namespace,
|
|
1028
|
-
tenant_id=tenant_id,
|
|
1029
|
-
workspace_id=workspace_id,
|
|
1030
|
-
store=store,
|
|
1031
|
-
session_events=session_events,
|
|
1032
|
-
session_service=session_service,
|
|
1033
|
-
runtime_executor=runtime_executor,
|
|
1034
|
-
launch_context=launch_context,
|
|
1035
|
-
pool=pool,
|
|
1036
|
-
owns_pool=owns_pool,
|
|
1037
|
-
# Operator 通过 downward API 注入 POD_UID。与 stable instance id
|
|
1038
|
-
# 组合才是 activation owner;hosted 少了它必须拒绝启动,不能退回到
|
|
1039
|
-
# 所有副本共享的固定字符串。
|
|
1040
|
-
activation_id=f"{agent_instance_id}:{pod_uid}" if pod_uid else None,
|
|
1041
|
-
lease_ttl_seconds=float(os.environ.get("AGENT_KERNEL_LEASE_TTL_SECONDS", "60") or "60"),
|
|
1042
|
-
)
|
|
1043
|
-
runtime = build_agent_kernel_runtime(config)
|
|
1044
|
-
try:
|
|
1045
|
-
if before_start is not None:
|
|
1046
|
-
await before_start(runtime)
|
|
1047
|
-
await runtime.start()
|
|
1048
|
-
except BaseException:
|
|
1049
|
-
await runtime.close()
|
|
1050
|
-
raise
|
|
1051
|
-
set_agent_kernel(runtime.kernel)
|
|
1052
|
-
set_agent_kernel_runtime(runtime)
|
|
1053
|
-
return runtime
|
|
1054
|
-
|
|
1055
1171
|
|
|
1056
1172
|
__all__ = [
|
|
1057
1173
|
"AgentKernelRuntime",
|