agentengine-sdk-python 0.8.6__py3-none-any.whl → 0.8.7__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.7.dist-info}/METADATA +31 -13
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/RECORD +655 -501
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/WHEEL +1 -1
- ksadk/_build_provenance.json +1 -1
- 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/agui/_agent_helpers.py +16 -1
- ksadk/agui/_agent_kernel.py +481 -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 +110 -566
- ksadk/agui/config.py +19 -5
- ksadk/agui/routes.py +2 -0
- ksadk/api/client.py +158 -7
- ksadk/builders/code_builder.py +144 -29
- ksadk/builders/container_builder.py +27 -6
- ksadk/builders/framework_requirements.py +5 -4
- ksadk/builders/mcp_builder.py +3 -1
- ksadk/cli/cmd_deploy.py +5 -0
- ksadk/cli/cmd_invoke.py +57 -2
- ksadk/cli/cmd_studio.py +19 -3
- ksadk/cli/cmd_web.py +20 -56
- ksadk/cli/hosted_command_events.py +148 -0
- ksadk/cli/hosted_invoke.py +66 -14
- ksadk/cli/runtime_bootstrap.py +1 -0
- ksadk/codex/async_client.py +354 -12
- ksadk/codex/runtime.py +17 -2
- ksadk/common/diagnostics.py +15 -0
- ksadk/compat/copilotkit_a2ui.py +85 -21
- ksadk/configs/env_registry.py +71 -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 +29 -0
- ksadk/conversations/runtime_invocation.py +3 -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/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/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/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/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 +63 -11
- 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 +89 -200
- ksadk/kernel/worker_controls.py +112 -27
- ksadk/kernel/worker_interactions.py +343 -47
- ksadk/knowledge_base/__init__.py +1 -1
- ksadk/knowledge_base/client.py +128 -14
- 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 +147 -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 +402 -0
- ksadk/mcp_runtime/oauth/local/__init__.py +1 -0
- ksadk/mcp_runtime/oauth/local/broker.py +469 -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 +396 -0
- ksadk/mcp_runtime/oauth/transport.py +92 -0
- 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/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_tools.py +39 -2
- ksadk/resource_runtime/contracts.py +8 -3
- ksadk/resource_runtime/knowledge.py +1 -1
- ksadk/resource_runtime/managed_projection.py +24 -9
- ksadk/resource_runtime/worker.py +5 -1
- ksadk/runners/_adk_a2a_stream.py +10 -0
- ksadk/runners/_langgraph_answer_contract.py +47 -0
- ksadk/runners/_langgraph_canonical_stream.py +641 -0
- ksadk/runners/_langgraph_checkpoint_binding.py +89 -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 +32 -75
- ksadk/runners/_langgraph_state_reader.py +5 -0
- ksadk/runners/_langgraph_wait_cancellation.py +49 -0
- ksadk/runners/_session_identity.py +22 -1
- ksadk/runners/adk_runner.py +13 -3
- ksadk/runners/base_runner.py +21 -0
- ksadk/runners/langgraph_runner.py +128 -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/framework_adapters.py +27 -2
- ksadk/runtime/langgraph_checkpoint_view.py +147 -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 +125 -3
- ksadk/server/history_deadline.py +20 -4
- ksadk/server/history_page_cache.py +8 -2
- ksadk/server/routes/common.py +11 -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/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 +251 -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/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 +368 -9
- ksadk/studio/dsh_application.py +17 -4
- ksadk/studio/execution_host.py +10 -5
- ksadk/studio/interaction_submission.py +7 -2
- 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_model_port.py +201 -43
- ksadk/studio/native_planning.py +43 -2
- ksadk/studio/native_product.py +238 -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_kernel_adapter.py +13 -0
- ksadk/studio/plugin_native_activation.py +2 -2
- 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 +99 -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 +58 -3
- 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 +1 -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.7.dist-info}/entry_points.txt +0 -0
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.dist-info}/licenses/LICENSE +0 -0
- {agentengine_sdk_python-0.8.6.dist-info → agentengine_sdk_python-0.8.7.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/harness/native/engine.py
CHANGED
|
@@ -15,6 +15,7 @@ from uuid import uuid4
|
|
|
15
15
|
|
|
16
16
|
from ksadk.harness.stores.native_contract import (
|
|
17
17
|
ForkingRunStore,
|
|
18
|
+
NotificationTurnCreation,
|
|
18
19
|
PendingCommandConflict,
|
|
19
20
|
RunStore,
|
|
20
21
|
StoreConflict,
|
|
@@ -22,6 +23,7 @@ from ksadk.harness.stores.native_contract import (
|
|
|
22
23
|
)
|
|
23
24
|
|
|
24
25
|
from .activation_contract import ActivationResourceRef
|
|
26
|
+
from .background_command_contract import BackgroundCommandPort
|
|
25
27
|
from .child_interruption import admit_interrupted_child_receipts as admit_interrupted_child_receipts
|
|
26
28
|
from .child_lifecycle import (
|
|
27
29
|
ChildLifecyclePort,
|
|
@@ -133,6 +135,7 @@ from .state import (
|
|
|
133
135
|
)
|
|
134
136
|
from .stop_hook_runtime import prepare_stop_hook
|
|
135
137
|
from .stop_hook_runtime import reduce_stop_hook as reduce_stop_hook
|
|
138
|
+
from .stream_display_buffer import StreamDisplayBuffer
|
|
136
139
|
from .tool_hook_runtime import (
|
|
137
140
|
close_tool_hook_run as close_tool_hook_run,
|
|
138
141
|
)
|
|
@@ -175,6 +178,7 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
175
178
|
context_port: ContextPort | None = None,
|
|
176
179
|
hook_port: HookPort | None = None,
|
|
177
180
|
child_lifecycle_port: ChildLifecyclePort | None = None,
|
|
181
|
+
background_command_port: BackgroundCommandPort | None = None,
|
|
178
182
|
workspace_revision: str = "unavailable",
|
|
179
183
|
lease_ttl_seconds: float | None = None,
|
|
180
184
|
activation_resource: ActivationResourceRef | None = None,
|
|
@@ -215,6 +219,10 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
215
219
|
getattr(child_lifecycle_port, "ready_children", None)
|
|
216
220
|
):
|
|
217
221
|
raise ValueError("configured child notifications require their host Port")
|
|
222
|
+
if configuration.background_notification_policy and not callable(
|
|
223
|
+
getattr(background_command_port, "observe", None)
|
|
224
|
+
):
|
|
225
|
+
raise ValueError("configured background notifications require their host Port")
|
|
218
226
|
if configuration.child_approval_policy and not getattr(
|
|
219
227
|
child_lifecycle_port, "approval_bridge", False
|
|
220
228
|
):
|
|
@@ -255,10 +263,12 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
255
263
|
)
|
|
256
264
|
self._clock = ActiveRunClock(configuration.limits.max_wall_seconds)
|
|
257
265
|
self._child_promotion = child_lifecycle_port
|
|
266
|
+
self._background_commands = background_command_port
|
|
258
267
|
self._locks: dict[str, asyncio.Lock] = {}
|
|
259
268
|
self._parallel_progress_locks: dict[str, asyncio.Lock] = {}
|
|
260
269
|
self._wakes: dict[str, asyncio.Event] = {}
|
|
261
270
|
self._finalization_recovery_fences: dict[str, int] = {}
|
|
271
|
+
self._stream_buffers: dict[str, StreamDisplayBuffer] = {}
|
|
262
272
|
|
|
263
273
|
def start(
|
|
264
274
|
self,
|
|
@@ -271,6 +281,7 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
271
281
|
expected_parent_run_id: str | None = None,
|
|
272
282
|
pin_parent: bool = False,
|
|
273
283
|
user_input: NativeUserInput | None = None,
|
|
284
|
+
task_chain_id: str | None = None,
|
|
274
285
|
) -> RunSnapshot:
|
|
275
286
|
config = self.configuration
|
|
276
287
|
if user_input is not None:
|
|
@@ -310,6 +321,7 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
310
321
|
initial_goal_digest=hashlib.sha256(goal.encode("utf-8")).hexdigest(),
|
|
311
322
|
messages=(*history, *(user_input.messages() if user_input is not None
|
|
312
323
|
else ({"role": "user", "content": goal},))),
|
|
324
|
+
background_commands=parent.background_commands if parent else (),
|
|
313
325
|
task_progress=parent.task_progress if parent else (),
|
|
314
326
|
task_progress_revision=parent.task_progress_revision if parent else 0,
|
|
315
327
|
workspace_revision=(
|
|
@@ -341,7 +353,15 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
341
353
|
self._activation_resource.model_dump(mode="json")
|
|
342
354
|
if self._activation_resource is not None else None
|
|
343
355
|
),
|
|
356
|
+
task_chain_id=task_chain_id,
|
|
357
|
+
)
|
|
358
|
+
from .context_session_history import inherit_session_summary
|
|
359
|
+
|
|
360
|
+
inherited_summary = inherit_session_summary(
|
|
361
|
+
parent, snapshot, config, self.context, imported_count=len(history),
|
|
344
362
|
)
|
|
363
|
+
if inherited_summary is not None:
|
|
364
|
+
snapshot = snapshot.model_copy(update={"compaction_history": inherited_summary})
|
|
345
365
|
self.store.create_turn(snapshot, expected_parent_run_id=parent.run_id if parent else None)
|
|
346
366
|
self.attach(snapshot.run_id)
|
|
347
367
|
return self.snapshot(snapshot.run_id)
|
|
@@ -399,6 +419,310 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
399
419
|
self.attach(result.snapshot.run_id)
|
|
400
420
|
return result
|
|
401
421
|
|
|
422
|
+
def start_notification_turn(
|
|
423
|
+
self,
|
|
424
|
+
*,
|
|
425
|
+
source_run_id: str,
|
|
426
|
+
task_id: str,
|
|
427
|
+
task_contract: TaskContract | None = None,
|
|
428
|
+
) -> NotificationTurnCreation:
|
|
429
|
+
"""Admit a background-notification turn in the source run's session.
|
|
430
|
+
|
|
431
|
+
Creates a new run in the *same session* with a deterministic run id, inheriting
|
|
432
|
+
the source's goal (task continuity), background commands and task-chain identity.
|
|
433
|
+
No synthetic user prompt is added — the kernel's ``command_probe`` injects the
|
|
434
|
+
``background_command_observation`` message at the PREPARING_CONTEXT boundary.
|
|
435
|
+
|
|
436
|
+
Pre-checks: source must be terminal; the task must exist in the source's
|
|
437
|
+
background commands and not already be notified; the source must not be
|
|
438
|
+
canceled/failed. Repeat admissions with a matching request digest return the
|
|
439
|
+
already-created turn and re-attach it so it can be driven (not a permanent
|
|
440
|
+
stub); a different request for the same task_id is rejected by the store.
|
|
441
|
+
Never revives a terminal run or reuses an unconfirmed effect.
|
|
442
|
+
"""
|
|
443
|
+
from .notification_admission import (
|
|
444
|
+
build_notification_snapshot,
|
|
445
|
+
notification_request_command,
|
|
446
|
+
notification_run_id,
|
|
447
|
+
)
|
|
448
|
+
|
|
449
|
+
source = self.store.load(self.scope, source_run_id)
|
|
450
|
+
check_scope(self.scope, source)
|
|
451
|
+
if not source.phase.terminal:
|
|
452
|
+
raise StoreConflict("notification turn requires a terminal source run")
|
|
453
|
+
# The task must actually exist in the source run's owned background commands.
|
|
454
|
+
if not any(item.ref.task_id == task_id for item in source.background_commands):
|
|
455
|
+
raise StoreConflict("background_command_task_not_found")
|
|
456
|
+
if source.phase in {RunPhase.CANCELED, RunPhase.INTERRUPTED, RunPhase.FAILED}:
|
|
457
|
+
raise StoreConflict("notification source run is canceled or failed")
|
|
458
|
+
contract = task_contract or self.configuration.contract
|
|
459
|
+
validate_task_tool_scope(contract, self.configuration.tools)
|
|
460
|
+
run_id = notification_run_id(self.scope, source_run_id, task_id)
|
|
461
|
+
head = self.store.session_head(self.scope, source.session_id)
|
|
462
|
+
# Idempotent re-admission: a notification turn with this deterministic run
|
|
463
|
+
# id may already exist in the durable store. A repeat admission (retry or
|
|
464
|
+
# crash-recovery) must re-attach and re-drive the existing run rather than
|
|
465
|
+
# rebuild its snapshot (``project_session_history`` requires a terminal
|
|
466
|
+
# parent and fails for a non-terminal head — the crash window between the
|
|
467
|
+
# durable commit and the driver finishing, where the run may be at
|
|
468
|
+
# PREPARING_CONTEXT with the observation staged but no model intent yet).
|
|
469
|
+
# This fastpath runs BEFORE the already-notified pre-check: a staged
|
|
470
|
+
# observation sets ``notified=True`` on the run's background commands
|
|
471
|
+
# before the model turn, so the head (which is this unfinished run) would
|
|
472
|
+
# trip the already-notified check and discard an unfinished turn. The
|
|
473
|
+
# existing run is recovered instead — re-driven to the model boundary by
|
|
474
|
+
# the caller's ``register_and_drive_notification_turn``. ``notified`` on a
|
|
475
|
+
# recovered run is the exactly-once observation ledger; the kernel's
|
|
476
|
+
# ``command_probe`` does not re-inject already-notified commands, so the
|
|
477
|
+
# model receives the staged observation exactly once.
|
|
478
|
+
try:
|
|
479
|
+
existing = self.store.load(self.scope, run_id)
|
|
480
|
+
except KeyError:
|
|
481
|
+
existing = None
|
|
482
|
+
if existing is not None:
|
|
483
|
+
# Validate the request identity on the attach path: the immutable
|
|
484
|
+
# admission request (scope/session/source/task/configuration/profile/
|
|
485
|
+
# contract/chain/origin) must match the existing turn. A changed
|
|
486
|
+
# explicit task_contract (or any other request-identity field) is
|
|
487
|
+
# rejected — mirroring ``duplicate_notification_turn``'s request-digest
|
|
488
|
+
# contract, without rebuilding the snapshot from a nonterminal head.
|
|
489
|
+
proposed_command = notification_request_command(
|
|
490
|
+
source, task_id=task_id, configuration=self.configuration,
|
|
491
|
+
contract=contract, context_binding=self.context.binding,
|
|
492
|
+
parent_run_id=head.run_id if head else source_run_id,
|
|
493
|
+
snapshot_source=head if head is not None else source,
|
|
494
|
+
)
|
|
495
|
+
if existing.notification_command != proposed_command:
|
|
496
|
+
raise StoreConflict(
|
|
497
|
+
"notification turn was already used with another request"
|
|
498
|
+
)
|
|
499
|
+
self.attach(existing.run_id)
|
|
500
|
+
return NotificationTurnCreation(snapshot=existing, created=False)
|
|
501
|
+
# No existing run: the already-notified pre-check now guards against a
|
|
502
|
+
# task a prior (terminal) notification turn already delivered, when that
|
|
503
|
+
# turn's run is not found by the deterministic id (a durable-store
|
|
504
|
+
# inconsistency safety net). Check the CURRENT head's background_commands
|
|
505
|
+
# (cumulative notified state from prior notification turns).
|
|
506
|
+
notified_source = head if head is not None else source
|
|
507
|
+
if any(item.ref.task_id == task_id and item.notified
|
|
508
|
+
for item in notified_source.background_commands):
|
|
509
|
+
raise StoreConflict("background_command_already_notified")
|
|
510
|
+
# A public/manual admission must meet the same real completion gate as
|
|
511
|
+
# the idle coordinator. Unavailable observations and a still-running
|
|
512
|
+
# command retain the watch; they must not consume its dedup marker.
|
|
513
|
+
from .background_command_contract import BackgroundCommandRequest
|
|
514
|
+
|
|
515
|
+
refs = tuple(item.ref for item in source.background_commands if item.ref.task_id == task_id)
|
|
516
|
+
observations = self._background_commands.observe(BackgroundCommandRequest(
|
|
517
|
+
scope=self.scope, run_id=source.run_id, session_id=source.session_id, refs=refs,
|
|
518
|
+
)) if self._background_commands is not None else ()
|
|
519
|
+
if not any(item.ref == refs[0] and item.status in {
|
|
520
|
+
"completed", "failed", "cancelled", "timed_out", "output_limit",
|
|
521
|
+
} for item in observations):
|
|
522
|
+
raise StoreConflict("background_command_not_terminal")
|
|
523
|
+
# The parent for CAS is the current session head, NOT the original source
|
|
524
|
+
# run. After the first notification turn moves the head, subsequent
|
|
525
|
+
# notifications for other tasks in the same source must CAS against the
|
|
526
|
+
# current head (the prior notification turn), not the original source.
|
|
527
|
+
expected_parent = head.run_id if head else source_run_id
|
|
528
|
+
# Build the snapshot from the CURRENT head (not the original source) so
|
|
529
|
+
# that background_commands carry the cumulative notified state from prior
|
|
530
|
+
# notification turns. The original source is used only for the
|
|
531
|
+
# task-existence and already-notified pre-checks above, and for the
|
|
532
|
+
# notification_command's source_run_id binding.
|
|
533
|
+
snapshot_source = head if head is not None else source
|
|
534
|
+
snapshot = build_notification_snapshot(
|
|
535
|
+
source, run_id=run_id, turn_id=str(uuid4()), task_id=task_id,
|
|
536
|
+
configuration=self.configuration, contract=contract,
|
|
537
|
+
context_binding=self.context.binding,
|
|
538
|
+
workspace_revision=self.context.workspace_revision,
|
|
539
|
+
parent_run_id=expected_parent,
|
|
540
|
+
snapshot_source=snapshot_source,
|
|
541
|
+
)
|
|
542
|
+
result = self.store.create_notification_turn(
|
|
543
|
+
snapshot, expected_parent_run_id=expected_parent,
|
|
544
|
+
)
|
|
545
|
+
# Always attach (both created and idempotent repeat) so the turn can be
|
|
546
|
+
# driven. A repeat admission re-enters the existing run, which the driver
|
|
547
|
+
# resumes from its committed phase — not a permanent stub.
|
|
548
|
+
self.attach(result.snapshot.run_id)
|
|
549
|
+
return result
|
|
550
|
+
|
|
551
|
+
def notified_task_ids(self, run_id: str) -> set[str]:
|
|
552
|
+
"""Return the set of task_ids already delivered in a run's ledger."""
|
|
553
|
+
snapshot = self.snapshot(run_id)
|
|
554
|
+
return {item.ref.task_id for item in snapshot.background_commands if item.notified}
|
|
555
|
+
|
|
556
|
+
def is_run_canceled(self, run_id: str) -> bool:
|
|
557
|
+
"""Authoritative terminal-status query; replaces event-store inference."""
|
|
558
|
+
snapshot = self.snapshot(run_id)
|
|
559
|
+
return snapshot.phase in {RunPhase.CANCELED, RunPhase.INTERRUPTED, RunPhase.FAILED}
|
|
560
|
+
|
|
561
|
+
def task_chain_remaining_budget(self, run_id: str) -> int | None:
|
|
562
|
+
"""Remaining model-call budget for the run's task chain, or None if unbounded.
|
|
563
|
+
|
|
564
|
+
A notification turn inherits the source run's chain, so its budget accrues to
|
|
565
|
+
the original task. Returns None when the configuration has no explicit
|
|
566
|
+
``max_model_calls`` (ordinary unbounded runs). A finite budget subtracts the
|
|
567
|
+
chain's settled usage; the result is never negative (0 = exhausted).
|
|
568
|
+
"""
|
|
569
|
+
status = self.task_chain_budget_status(run_id)
|
|
570
|
+
return status["model_calls_remaining"]
|
|
571
|
+
|
|
572
|
+
def task_chain_budget_status(self, run_id: str) -> dict:
|
|
573
|
+
"""Remaining budget for the run's task chain across all dimensions.
|
|
574
|
+
|
|
575
|
+
Returns a dict with ``model_calls_remaining``, ``tool_calls_remaining``,
|
|
576
|
+
``wall_seconds_remaining`` — each None if that dimension is unbounded, or a
|
|
577
|
+
non-negative int/float if bounded (0 = exhausted). Raises StoreConflict
|
|
578
|
+
if a finite chain has no ledger or a read error (fail-closed).
|
|
579
|
+
"""
|
|
580
|
+
snapshot = self.snapshot(run_id)
|
|
581
|
+
if not snapshot.task_chain_id:
|
|
582
|
+
return {"model_calls_remaining": None, "tool_calls_remaining": None,
|
|
583
|
+
"wall_seconds_remaining": None}
|
|
584
|
+
limits = self.configuration.limits
|
|
585
|
+
if (limits.max_model_calls is None and limits.max_tool_calls is None
|
|
586
|
+
and limits.max_wall_seconds is None):
|
|
587
|
+
return {"model_calls_remaining": None, "tool_calls_remaining": None,
|
|
588
|
+
"wall_seconds_remaining": None}
|
|
589
|
+
usage = getattr(self.store, "task_chain_usage", None)
|
|
590
|
+
if usage is None:
|
|
591
|
+
raise StoreConflict(
|
|
592
|
+
"finite task-chain budget requires a usage ledger; store does not support one"
|
|
593
|
+
)
|
|
594
|
+
try:
|
|
595
|
+
chain = usage(self.scope, snapshot.task_chain_id)
|
|
596
|
+
except Exception as exc:
|
|
597
|
+
raise StoreConflict("task-chain usage read failed") from exc
|
|
598
|
+
# If the current run is already settled, its usage is in chain totals.
|
|
599
|
+
settled_ids = getattr(self.store, "chain_settled_run_ids", None)
|
|
600
|
+
if callable(settled_ids):
|
|
601
|
+
try:
|
|
602
|
+
already_settled = snapshot.run_id in settled_ids(
|
|
603
|
+
self.scope, snapshot.task_chain_id
|
|
604
|
+
)
|
|
605
|
+
except Exception as exc:
|
|
606
|
+
raise StoreConflict("chain settled-runs read failed") from exc
|
|
607
|
+
else:
|
|
608
|
+
raise StoreConflict("chain settled-runs read failed")
|
|
609
|
+
if already_settled:
|
|
610
|
+
chain_model = chain.model_calls + chain.descendant_model_calls
|
|
611
|
+
chain_tool = chain.tool_calls + chain.descendant_tool_calls
|
|
612
|
+
chain_wall = chain.execution_elapsed_seconds
|
|
613
|
+
else:
|
|
614
|
+
chain_model = (chain.model_calls + snapshot.model_calls
|
|
615
|
+
+ chain.descendant_model_calls + snapshot.descendant_model_calls)
|
|
616
|
+
chain_tool = (chain.tool_calls + snapshot.tool_calls
|
|
617
|
+
+ chain.descendant_tool_calls + snapshot.descendant_tool_calls)
|
|
618
|
+
chain_wall = chain.execution_elapsed_seconds + snapshot.execution_elapsed_seconds
|
|
619
|
+
return {
|
|
620
|
+
"model_calls_remaining": (
|
|
621
|
+
None if limits.max_model_calls is None
|
|
622
|
+
else max(0, limits.max_model_calls - chain_model)
|
|
623
|
+
),
|
|
624
|
+
"tool_calls_remaining": (
|
|
625
|
+
None if limits.max_tool_calls is None
|
|
626
|
+
else max(0, limits.max_tool_calls - chain_tool)
|
|
627
|
+
),
|
|
628
|
+
"wall_seconds_remaining": (
|
|
629
|
+
None if limits.max_wall_seconds is None
|
|
630
|
+
else max(0.0, limits.max_wall_seconds - chain_wall)
|
|
631
|
+
),
|
|
632
|
+
}
|
|
633
|
+
|
|
634
|
+
def _check_chain_budget_exhausted(self, snapshot: RunSnapshot) -> CommitBatch | None:
|
|
635
|
+
"""Check if the task chain's cumulative model/wall budget is exhausted.
|
|
636
|
+
|
|
637
|
+
Returns a terminal CommitBatch if the chain's model or wall budget is
|
|
638
|
+
confirmed exhausted, or None otherwise. Uses the already-loaded
|
|
639
|
+
snapshot — does not reload from store.
|
|
640
|
+
|
|
641
|
+
The tool dimension is NOT checked here: the chain's already-consumed
|
|
642
|
+
tool budget is folded into the effective per-run tool limit by
|
|
643
|
+
``effective_configuration``, so the canonical per-call boundary
|
|
644
|
+
(``tools_exhausted`` / ``model_turn_control``) enforces it with *soft
|
|
645
|
+
finalization* — a tools-spent chain admits no tools but the model still
|
|
646
|
+
produces a final answer (preserving final-submission/reserve). A hard
|
|
647
|
+
finish here would bypass that lawful finalization.
|
|
648
|
+
|
|
649
|
+
Model exhaustion hard-finishes only when the chain has *actually
|
|
650
|
+
consumed* model calls (chain_model > 0) and reached the cap — no answer
|
|
651
|
+
is possible once the model budget is spent. A finite model budget with
|
|
652
|
+
zero consumption is terminated at the PREPARING_CONTEXT boundary by the
|
|
653
|
+
per-call ``model_budget_exhausted`` check, not here. Wall budget has no
|
|
654
|
+
per-call boundary and is checked unconditionally (elapsed time is real
|
|
655
|
+
consumption, never a zero-with-no-consumption case).
|
|
656
|
+
|
|
657
|
+
A finite chain with a missing or unreadable ledger is a hard failure:
|
|
658
|
+
the run cannot be admitted because the host cannot prove it has budget
|
|
659
|
+
remaining. Read errors raise StoreConflict (fail-closed), not silently
|
|
660
|
+
granted. A new task starts with a zero ledger created atomically by the
|
|
661
|
+
in-commit settlement; a missing ledger for an existing finite chain is
|
|
662
|
+
not the same as zero consumption.
|
|
663
|
+
"""
|
|
664
|
+
if not snapshot.task_chain_id:
|
|
665
|
+
return None
|
|
666
|
+
max_model = self.configuration.limits.max_model_calls
|
|
667
|
+
max_tool = self.configuration.limits.max_tool_calls
|
|
668
|
+
max_wall = self.configuration.limits.max_wall_seconds
|
|
669
|
+
if max_model is None and max_tool is None and max_wall is None:
|
|
670
|
+
return None # fully unbounded — no check
|
|
671
|
+
chain = getattr(self.store, "task_chain_usage", None)
|
|
672
|
+
if chain is None:
|
|
673
|
+
raise StoreConflict(
|
|
674
|
+
"finite task-chain budget requires a usage ledger; store does not support one"
|
|
675
|
+
)
|
|
676
|
+
try:
|
|
677
|
+
usage = chain(self.scope, snapshot.task_chain_id)
|
|
678
|
+
except Exception as exc:
|
|
679
|
+
raise StoreConflict("task-chain usage read failed") from exc
|
|
680
|
+
# The chain ledger entry is created atomically at create_turn time.
|
|
681
|
+
# task_chain_usage raises StoreConflict if the entry is missing (deleted/
|
|
682
|
+
# corrupted). A registered zero entry is valid — a new chain that has not
|
|
683
|
+
# consumed anything yet. No heuristic scan needed.
|
|
684
|
+
# If the current run is already settled, its usage is already in the chain
|
|
685
|
+
# totals — do NOT add snapshot.model_calls again (would double-count).
|
|
686
|
+
# If not yet settled, add the current run's unssettled contribution.
|
|
687
|
+
# A read error from chain_settled_run_ids is NOT the same as "not settled" —
|
|
688
|
+
# it means we cannot prove the settlement status. Fail-closed: raise.
|
|
689
|
+
settled_ids = getattr(self.store, "chain_settled_run_ids", None)
|
|
690
|
+
if callable(settled_ids):
|
|
691
|
+
try:
|
|
692
|
+
already_settled = snapshot.run_id in settled_ids(
|
|
693
|
+
self.scope, snapshot.task_chain_id
|
|
694
|
+
)
|
|
695
|
+
except Exception as exc:
|
|
696
|
+
raise StoreConflict("chain settled-runs read failed") from exc
|
|
697
|
+
else:
|
|
698
|
+
raise StoreConflict("chain settled-runs read failed")
|
|
699
|
+
if already_settled:
|
|
700
|
+
chain_model = usage.model_calls + usage.descendant_model_calls
|
|
701
|
+
chain_wall = usage.execution_elapsed_seconds
|
|
702
|
+
else:
|
|
703
|
+
chain_model = (usage.model_calls + snapshot.model_calls
|
|
704
|
+
+ usage.descendant_model_calls + snapshot.descendant_model_calls)
|
|
705
|
+
chain_wall = usage.execution_elapsed_seconds + snapshot.execution_elapsed_seconds
|
|
706
|
+
if max_model is not None and chain_model > 0 and max_model - chain_model <= 0:
|
|
707
|
+
return commit_transition(
|
|
708
|
+
snapshot, finish(snapshot, "budget_exhausted", "chain_model_calls_exhausted"),
|
|
709
|
+
"budget.exhausted", {"reason": "chain_model_calls_exhausted"},
|
|
710
|
+
)
|
|
711
|
+
# The tool dimension is NOT hard-finished here. The chain's already-
|
|
712
|
+
# consumed tool budget is folded into the effective per-run tool limit
|
|
713
|
+
# by effective_configuration, so the canonical per-call boundary
|
|
714
|
+
# (tools_exhausted / model_turn_control) enforces it with soft
|
|
715
|
+
# finalization: a tools-spent chain admits no tools but the model still
|
|
716
|
+
# produces a final answer. A hard finish here would bypass the model's
|
|
717
|
+
# final-submission/reserve path. The model dimension above is the only
|
|
718
|
+
# hard finish (no answer is possible once the model budget is spent).
|
|
719
|
+
if max_wall is not None and max_wall - chain_wall <= 0:
|
|
720
|
+
return wall_budget_stop(
|
|
721
|
+
snapshot, self.store, self.scope,
|
|
722
|
+
elapsed=self._clock.elapsed(snapshot),
|
|
723
|
+
)
|
|
724
|
+
return None
|
|
725
|
+
|
|
402
726
|
def attach(self, run_id: str) -> RunSnapshot:
|
|
403
727
|
snapshot = self.snapshot(run_id)
|
|
404
728
|
if not self._leases.attached(run_id):
|
|
@@ -499,7 +823,122 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
499
823
|
return snapshot
|
|
500
824
|
|
|
501
825
|
def effective_configuration(self, snapshot: RunSnapshot) -> RunConfiguration:
|
|
502
|
-
|
|
826
|
+
config = effective_run_configuration(self.configuration, snapshot)
|
|
827
|
+
# Fold the task chain's PRIOR settled usage into the effective per-run
|
|
828
|
+
# limits so the canonical per-call boundary enforces the cumulative
|
|
829
|
+
# chain cap with *soft finalization*. Both the MODEL and TOOL dimensions
|
|
830
|
+
# must reflect prior chain consumption: a continuation in a chain that
|
|
831
|
+
# already used model/tool calls must have its effective per-run limit
|
|
832
|
+
# reduced by the prior settled total (parent + descendant), minus this
|
|
833
|
+
# run's own already-settled contribution (to avoid double-counting).
|
|
834
|
+
# The current run's per-run consumption is tracked by
|
|
835
|
+
# snapshot.model_budget_claimed / snapshot.tool_budget_claimed and
|
|
836
|
+
# enforced by the per-call boundary against this effective limit.
|
|
837
|
+
if not snapshot.task_chain_id:
|
|
838
|
+
return config
|
|
839
|
+
max_model = self.configuration.limits.max_model_calls
|
|
840
|
+
max_tool = self.configuration.limits.max_tool_calls
|
|
841
|
+
if max_model is None and max_tool is None:
|
|
842
|
+
return config
|
|
843
|
+
chain_usage = getattr(self.store, "task_chain_usage", None)
|
|
844
|
+
if chain_usage is None:
|
|
845
|
+
raise StoreConflict(
|
|
846
|
+
"finite task-chain budget requires a usage ledger"
|
|
847
|
+
)
|
|
848
|
+
try:
|
|
849
|
+
usage = chain_usage(self.scope, snapshot.task_chain_id)
|
|
850
|
+
except Exception:
|
|
851
|
+
# A finite chain with an unreadable ledger is fail-closed: cannot
|
|
852
|
+
# prove cumulative budget remaining, so do NOT silently grant a fresh
|
|
853
|
+
# per-run limit. Raise so the per-call boundary sees an exhausted
|
|
854
|
+
# effective limit rather than authorizing new side effects.
|
|
855
|
+
raise StoreConflict("task-chain usage read failed")
|
|
856
|
+
settled_ids = getattr(self.store, "chain_settled_run_ids", None)
|
|
857
|
+
if callable(settled_ids):
|
|
858
|
+
try:
|
|
859
|
+
already_settled = snapshot.run_id in settled_ids(
|
|
860
|
+
self.scope, snapshot.task_chain_id
|
|
861
|
+
)
|
|
862
|
+
except Exception as exc:
|
|
863
|
+
raise StoreConflict("chain settled-runs read failed") from exc
|
|
864
|
+
else:
|
|
865
|
+
raise StoreConflict("chain settled-runs read failed")
|
|
866
|
+
# Prior settled usage = the chain's settled total (parent + descendant)
|
|
867
|
+
# minus this run's own settled contribution (if any), so the current
|
|
868
|
+
# turn is not double-counted.
|
|
869
|
+
if already_settled:
|
|
870
|
+
prior_model = (usage.model_calls + usage.descendant_model_calls
|
|
871
|
+
- snapshot.model_calls - snapshot.descendant_model_calls)
|
|
872
|
+
prior_tool = (usage.tool_calls + usage.descendant_tool_calls
|
|
873
|
+
- snapshot.tool_calls - snapshot.descendant_tool_calls)
|
|
874
|
+
else:
|
|
875
|
+
prior_model = usage.model_calls + usage.descendant_model_calls
|
|
876
|
+
prior_tool = usage.tool_calls + usage.descendant_tool_calls
|
|
877
|
+
updates = {}
|
|
878
|
+
if max_model is not None and prior_model > 0:
|
|
879
|
+
effective_model = max(0, max_model - prior_model)
|
|
880
|
+
if effective_model < max_model:
|
|
881
|
+
updates["max_model_calls"] = effective_model
|
|
882
|
+
if max_tool is not None and prior_tool > 0:
|
|
883
|
+
effective_tool = max(0, max_tool - prior_tool)
|
|
884
|
+
if effective_tool < max_tool:
|
|
885
|
+
updates["max_tool_calls"] = effective_tool
|
|
886
|
+
if not updates:
|
|
887
|
+
return config
|
|
888
|
+
limits = config.limits.model_copy(update=updates)
|
|
889
|
+
return config.model_copy(update={"limits": limits})
|
|
890
|
+
|
|
891
|
+
def _chain_wall_remaining(self, snapshot: RunSnapshot) -> float | None:
|
|
892
|
+
"""Remaining wall budget including the chain's prior settled elapsed time.
|
|
893
|
+
|
|
894
|
+
The per-run clock's ``remaining`` only subtracts this run's own elapsed
|
|
895
|
+
time from ``max_wall_seconds``. A continuation in a chain that already
|
|
896
|
+
consumed wall time must have its remaining budget reduced by the chain's
|
|
897
|
+
prior settled elapsed (parent + descendant), minus this run's own
|
|
898
|
+
already-settled contribution (to avoid double-counting). The current
|
|
899
|
+
run's own elapsed is already in ``_clock.remaining``; we additionally
|
|
900
|
+
subtract the prior chain elapsed so the cumulative does not exceed the
|
|
901
|
+
cap.
|
|
902
|
+
"""
|
|
903
|
+
max_wall = self.configuration.limits.max_wall_seconds
|
|
904
|
+
if max_wall is None:
|
|
905
|
+
return None
|
|
906
|
+
per_run_remaining = self._clock.remaining(snapshot)
|
|
907
|
+
if per_run_remaining is None:
|
|
908
|
+
return None
|
|
909
|
+
if not snapshot.task_chain_id:
|
|
910
|
+
return per_run_remaining
|
|
911
|
+
chain_usage = getattr(self.store, "task_chain_usage", None)
|
|
912
|
+
if chain_usage is None:
|
|
913
|
+
raise StoreConflict("finite task-chain budget requires a usage ledger")
|
|
914
|
+
try:
|
|
915
|
+
usage = chain_usage(self.scope, snapshot.task_chain_id)
|
|
916
|
+
except Exception:
|
|
917
|
+
# Fail-closed: cannot prove cumulative wall budget remaining.
|
|
918
|
+
# Do NOT return 0.0 (that fabricates exhaustion and stops the run
|
|
919
|
+
# with budget_exhausted despite real budget left). Raise so the
|
|
920
|
+
# caller blocks/retries rather than recording a fake terminal.
|
|
921
|
+
raise StoreConflict("chain wall usage read failed")
|
|
922
|
+
settled_ids = getattr(self.store, "chain_settled_run_ids", None)
|
|
923
|
+
if callable(settled_ids):
|
|
924
|
+
try:
|
|
925
|
+
already_settled = snapshot.run_id in settled_ids(
|
|
926
|
+
self.scope, snapshot.task_chain_id
|
|
927
|
+
)
|
|
928
|
+
except Exception as exc:
|
|
929
|
+
raise StoreConflict("chain settled-runs read failed") from exc
|
|
930
|
+
else:
|
|
931
|
+
raise StoreConflict("chain settled-runs read failed")
|
|
932
|
+
if already_settled:
|
|
933
|
+
prior_elapsed = (usage.execution_elapsed_seconds
|
|
934
|
+
- snapshot.execution_elapsed_seconds)
|
|
935
|
+
else:
|
|
936
|
+
prior_elapsed = usage.execution_elapsed_seconds
|
|
937
|
+
# The per-run clock already accounts for this run's own elapsed; subtract
|
|
938
|
+
# only the prior chain elapsed (settled runs of other runs in the chain).
|
|
939
|
+
return (max_wall - prior_elapsed
|
|
940
|
+
- self._clock.elapsed(snapshot)
|
|
941
|
+
- snapshot.model_recovery_debt_seconds)
|
|
503
942
|
|
|
504
943
|
def steer(
|
|
505
944
|
self,
|
|
@@ -673,7 +1112,7 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
673
1112
|
async def _wait_retry(self, snapshot: RunSnapshot) -> RunSnapshot | None:
|
|
674
1113
|
"""Wait under the driver's lease, while still admitting control commands."""
|
|
675
1114
|
while snapshot.retry_not_before > time():
|
|
676
|
-
remaining = self.
|
|
1115
|
+
remaining = self._chain_wall_remaining(snapshot)
|
|
677
1116
|
if remaining is not None and remaining <= 0:
|
|
678
1117
|
return self._commit(snapshot, wall_budget_stop(
|
|
679
1118
|
snapshot, self.store, self.scope, elapsed=self._clock.elapsed(snapshot)
|
|
@@ -681,7 +1120,7 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
681
1120
|
wake = self._wakes[snapshot.run_id]
|
|
682
1121
|
with suppress(asyncio.TimeoutError):
|
|
683
1122
|
await asyncio.wait_for(
|
|
684
|
-
wake.wait(), min(max(0, snapshot.retry_not_before - time()), 0.
|
|
1123
|
+
wake.wait(), min(max(0, snapshot.retry_not_before - time()), 0.5)
|
|
685
1124
|
)
|
|
686
1125
|
wake.clear()
|
|
687
1126
|
commands = self._runnable_commands(snapshot)
|
|
@@ -708,12 +1147,35 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
708
1147
|
if snapshot.phase in {RunPhase.PAUSED, RunPhase.AWAITING_INTERACTION}:
|
|
709
1148
|
return snapshot
|
|
710
1149
|
if snapshot.phase != RunPhase.FINALIZING and (
|
|
711
|
-
(remaining := self.
|
|
1150
|
+
(remaining := self._chain_wall_remaining(snapshot)) is not None and remaining <= 0
|
|
712
1151
|
):
|
|
713
1152
|
return self._commit(snapshot, wall_budget_stop(
|
|
714
1153
|
snapshot, self.store, self.scope, elapsed=self._clock.elapsed(snapshot)
|
|
715
1154
|
))
|
|
1155
|
+
# Chain-level budget: a finite task-chain budget exhausted by cumulative
|
|
1156
|
+
# consumption stops the run before dispatching new effects. This is a
|
|
1157
|
+
# separate check — it does not replace the pending-intent branch below
|
|
1158
|
+
# and never interrupts an in-flight (pending) effect. A finite chain
|
|
1159
|
+
# with a missing/unreadable ledger raises StoreConflict (fail-closed).
|
|
1160
|
+
if (snapshot.phase != RunPhase.FINALIZING
|
|
1161
|
+
and not snapshot.pending_intent
|
|
1162
|
+
and snapshot.task_chain_id):
|
|
1163
|
+
chain_stop = self._check_chain_budget_exhausted(snapshot)
|
|
1164
|
+
if chain_stop is not None:
|
|
1165
|
+
return self._commit(snapshot, chain_stop)
|
|
716
1166
|
if snapshot.pending_intent:
|
|
1167
|
+
from .background_commands import command_probe, stage_command_observations
|
|
1168
|
+
|
|
1169
|
+
command_request = command_probe(
|
|
1170
|
+
snapshot, self.effective_configuration(snapshot), pending
|
|
1171
|
+
)
|
|
1172
|
+
if command_request is not None:
|
|
1173
|
+
batch = stage_command_observations(
|
|
1174
|
+
snapshot, command_request,
|
|
1175
|
+
self._background_commands.observe(command_request), intent=pending,
|
|
1176
|
+
)
|
|
1177
|
+
if batch is not None:
|
|
1178
|
+
return self._commit(snapshot, batch)
|
|
717
1179
|
probe = child_ready_probe(snapshot, self.effective_configuration(snapshot), pending)
|
|
718
1180
|
if probe is not None:
|
|
719
1181
|
ready = self._child_promotion.ready_children(probe)
|
|
@@ -726,11 +1188,20 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
726
1188
|
if stopped is not None:
|
|
727
1189
|
return stopped
|
|
728
1190
|
config = self.effective_configuration(snapshot)
|
|
1191
|
+
from .background_commands import command_probe, stage_command_observations
|
|
1192
|
+
|
|
1193
|
+
command_request = command_probe(snapshot, config)
|
|
1194
|
+
if command_request is not None:
|
|
1195
|
+
batch = stage_command_observations(
|
|
1196
|
+
snapshot, command_request, self._background_commands.observe(command_request),
|
|
1197
|
+
)
|
|
1198
|
+
if batch is not None:
|
|
1199
|
+
return self._commit(snapshot, batch)
|
|
729
1200
|
child_batch = prepare_child_lifecycle(snapshot, config)
|
|
730
1201
|
if child_batch is not None:
|
|
731
1202
|
return self._commit(snapshot, child_batch)
|
|
732
1203
|
if snapshot.phase != RunPhase.FINALIZING and (
|
|
733
|
-
(remaining := self.
|
|
1204
|
+
(remaining := self._chain_wall_remaining(snapshot)) is not None and remaining <= 0
|
|
734
1205
|
):
|
|
735
1206
|
return self._commit(snapshot, wall_budget_stop(
|
|
736
1207
|
snapshot, self.store, self.scope, elapsed=self._clock.elapsed(snapshot)
|
|
@@ -741,9 +1212,33 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
741
1212
|
snapshot, self._finalization_recovery_fences[run_id]
|
|
742
1213
|
) or next_transition(snapshot, config)
|
|
743
1214
|
elif snapshot.phase == RunPhase.PREPARING_CONTEXT:
|
|
744
|
-
|
|
1215
|
+
from .execution_budget import observe_budget
|
|
1216
|
+
|
|
1217
|
+
observation = None
|
|
1218
|
+
if (self.context.planner is not None
|
|
1219
|
+
and self.context.planner.execution_budget_policy is not None):
|
|
1220
|
+
observation = observe_budget(
|
|
1221
|
+
snapshot, config, wall_remaining=self._chain_wall_remaining(snapshot),
|
|
1222
|
+
)
|
|
1223
|
+
batch = observation or self.context.prepare(snapshot, config)
|
|
745
1224
|
elif snapshot.phase == RunPhase.COMPACTING:
|
|
746
|
-
|
|
1225
|
+
# A summary retry can cross the delivery window without
|
|
1226
|
+
# returning to task preparation. Refresh only on crossing:
|
|
1227
|
+
# ordinary summary chunks/retries must retain their sealed
|
|
1228
|
+
# budget quote. Pending requests above retain sealed input.
|
|
1229
|
+
from .tool_budget import wall_delivery_only
|
|
1230
|
+
|
|
1231
|
+
observation = None
|
|
1232
|
+
reserve = config.limits.finalization_reserve_wall_seconds
|
|
1233
|
+
if (reserve and not wall_delivery_only(snapshot, config)
|
|
1234
|
+
and (remaining := self._chain_wall_remaining(snapshot)) is not None
|
|
1235
|
+
and remaining <= reserve):
|
|
1236
|
+
from .execution_budget import observe_budget
|
|
1237
|
+
|
|
1238
|
+
observation = observe_budget(
|
|
1239
|
+
snapshot, config, wall_remaining=remaining,
|
|
1240
|
+
)
|
|
1241
|
+
batch = (observation or prepare_precompact_hook(snapshot, config)
|
|
747
1242
|
or self.context.begin_summary(snapshot, config))
|
|
748
1243
|
elif snapshot.phase == RunPhase.VERIFYING and self.verifier is not None:
|
|
749
1244
|
batch = (prepare_stop_hook(snapshot, config)
|
|
@@ -791,6 +1286,79 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
791
1286
|
self._clock.committed(committed, now)
|
|
792
1287
|
return committed
|
|
793
1288
|
|
|
1289
|
+
def _flush_stream(self, run_id: str) -> None:
|
|
1290
|
+
"""Flush pending display events with prepared-batch retention.
|
|
1291
|
+
|
|
1292
|
+
On first attempt: construct CommitBatch via provisional_delta, call
|
|
1293
|
+
_clock.prepare_commit, try store.commit. If commit raises a
|
|
1294
|
+
non-StoreConflict exception (unknown result), retain the exact
|
|
1295
|
+
prepared batch, expected_revision, fencing_token, now. On retry:
|
|
1296
|
+
replay the SAME batch — store recovers via commit_id idempotency
|
|
1297
|
+
(checks commit_id before expected_revision). Prevents double-commit.
|
|
1298
|
+
|
|
1299
|
+
StoreConflict (CAS/fence) is a known failure — the commit did not
|
|
1300
|
+
happen, no prepared batch is retained, exception propagates without
|
|
1301
|
+
swallowing. The pending stays in the buffer for a fresh attempt.
|
|
1302
|
+
"""
|
|
1303
|
+
buffer = self._stream_buffers.get(run_id)
|
|
1304
|
+
if buffer is None or not buffer.has_pending:
|
|
1305
|
+
return
|
|
1306
|
+
event = buffer.peek()
|
|
1307
|
+
if event is None:
|
|
1308
|
+
return
|
|
1309
|
+
|
|
1310
|
+
current = self.snapshot(run_id)
|
|
1311
|
+
if getattr(event, "request_id", current.pending_intent) != current.pending_intent:
|
|
1312
|
+
# A successor owns the stream now. Old display-only chunks must not
|
|
1313
|
+
# poison its request or replay an obsolete prepared snapshot.
|
|
1314
|
+
self._stream_buffers.pop(run_id, None)
|
|
1315
|
+
return
|
|
1316
|
+
prepared = buffer.peek_prepared()
|
|
1317
|
+
if prepared is not None:
|
|
1318
|
+
prepared_batch, expected_revision, fencing_token, now = prepared
|
|
1319
|
+
committed = self.store.commit(
|
|
1320
|
+
self.scope, prepared_batch,
|
|
1321
|
+
expected_revision=expected_revision,
|
|
1322
|
+
fencing_token=fencing_token,
|
|
1323
|
+
)
|
|
1324
|
+
self._clock.committed(committed, now)
|
|
1325
|
+
buffer.clear_prepared()
|
|
1326
|
+
buffer.ack()
|
|
1327
|
+
return
|
|
1328
|
+
|
|
1329
|
+
current = self.snapshot(run_id)
|
|
1330
|
+
batch = provisional_delta(current, event)
|
|
1331
|
+
batch, now = self._clock.prepare_commit(current, batch)
|
|
1332
|
+
fencing_token = self.fencing_token(run_id)
|
|
1333
|
+
try:
|
|
1334
|
+
committed = self.store.commit(
|
|
1335
|
+
self.scope, batch,
|
|
1336
|
+
expected_revision=current.revision,
|
|
1337
|
+
fencing_token=fencing_token,
|
|
1338
|
+
)
|
|
1339
|
+
except StoreConflict:
|
|
1340
|
+
raise
|
|
1341
|
+
except Exception:
|
|
1342
|
+
buffer.store_prepared((batch, current.revision, fencing_token, now))
|
|
1343
|
+
raise
|
|
1344
|
+
self._clock.committed(committed, now)
|
|
1345
|
+
buffer.ack()
|
|
1346
|
+
|
|
1347
|
+
def _make_flush_callback(self, run_id: str):
|
|
1348
|
+
"""Create a synchronous flush callback for exchange deadline ticks.
|
|
1349
|
+
|
|
1350
|
+
Called within the drive lock (exchange runs in the locked task).
|
|
1351
|
+
CAS/fence/store errors propagate as StreamFlushError to distinguish
|
|
1352
|
+
from port errors.
|
|
1353
|
+
"""
|
|
1354
|
+
def _flush():
|
|
1355
|
+
try:
|
|
1356
|
+
self._flush_stream(run_id)
|
|
1357
|
+
except Exception as exc:
|
|
1358
|
+
from .model_runtime import StreamFlushError
|
|
1359
|
+
raise StreamFlushError(str(exc)) from exc
|
|
1360
|
+
return _flush
|
|
1361
|
+
|
|
794
1362
|
async def _apply_command(self, snapshot: RunSnapshot, command: RunCommand) -> RunSnapshot:
|
|
795
1363
|
if command.kind == "cancel_child":
|
|
796
1364
|
return await self._consume_child_cancellation(snapshot.run_id, command)
|
|
@@ -848,6 +1416,10 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
848
1416
|
return committed
|
|
849
1417
|
|
|
850
1418
|
async def _execute(self, snapshot: RunSnapshot) -> RunSnapshot:
|
|
1419
|
+
# Resolve an uncertain display commit while the original request still
|
|
1420
|
+
# owns the intent, before recovery may install a successor request.
|
|
1421
|
+
self._flush_stream_guarded(snapshot.run_id)
|
|
1422
|
+
snapshot = self.snapshot(snapshot.run_id)
|
|
851
1423
|
key = snapshot.pending_intent
|
|
852
1424
|
intent = self.store.get_intent(self.scope, snapshot.run_id, key)
|
|
853
1425
|
if intent is None:
|
|
@@ -914,20 +1486,30 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
914
1486
|
self.scope, snapshot.run_id, member_key,
|
|
915
1487
|
fencing_token=self.fencing_token(snapshot.run_id),
|
|
916
1488
|
)
|
|
1489
|
+
flush_callback = self._make_flush_callback(snapshot.run_id)
|
|
917
1490
|
receipt = await self._effects.dispatch(
|
|
918
1491
|
snapshot,
|
|
919
1492
|
intent,
|
|
920
1493
|
self.effective_configuration(snapshot),
|
|
921
1494
|
wake=self._wakes[snapshot.run_id],
|
|
922
1495
|
emit=lambda event: self._stream_delta(snapshot.run_id, event),
|
|
923
|
-
|
|
924
|
-
|
|
925
|
-
|
|
926
|
-
|
|
927
|
-
|
|
928
|
-
|
|
929
|
-
|
|
930
|
-
|
|
1496
|
+
flush_callback=flush_callback,
|
|
1497
|
+
flush_interval=0.2,
|
|
1498
|
+
on_child_promotion=lambda command: (
|
|
1499
|
+
self._flush_stream_guarded(snapshot.run_id),
|
|
1500
|
+
self._consume_child_promotion(snapshot.run_id, command),
|
|
1501
|
+
)[1],
|
|
1502
|
+
on_child_input=lambda command: (
|
|
1503
|
+
self._flush_stream_guarded(snapshot.run_id),
|
|
1504
|
+
self._consume_child_input(snapshot.run_id, command),
|
|
1505
|
+
)[1],
|
|
1506
|
+
on_child_cancellation=lambda command: (
|
|
1507
|
+
self._flush_stream_guarded(snapshot.run_id),
|
|
1508
|
+
self._consume_child_cancellation(
|
|
1509
|
+
snapshot.run_id, command,
|
|
1510
|
+
),
|
|
1511
|
+
)[1],
|
|
1512
|
+
remaining_wall_seconds=self._chain_wall_remaining(snapshot),
|
|
931
1513
|
reconcile_tool=reconcile_tool,
|
|
932
1514
|
on_parallel_child=(
|
|
933
1515
|
lambda index, raw_call, operation_key, result: self._commit_parallel_child(
|
|
@@ -939,7 +1521,10 @@ class NativeKernel(EffectReceiptCommitter):
|
|
|
939
1521
|
)
|
|
940
1522
|
interrupted = receipt
|
|
941
1523
|
receipt = self._interrupted_child_receipt(self.snapshot(snapshot.run_id), intent, receipt)
|
|
942
|
-
|
|
1524
|
+
self._flush_stream_guarded(snapshot.run_id)
|
|
1525
|
+
result = self._commit_receipt(
|
|
943
1526
|
self.snapshot(snapshot.run_id), intent, receipt, reconciled=reconcile_tool,
|
|
944
1527
|
interruption=interrupted if receipt is not interrupted else None,
|
|
945
1528
|
)
|
|
1529
|
+
self._stream_buffers.pop(snapshot.run_id, None)
|
|
1530
|
+
return result
|